> ## Documentation Index
> Fetch the complete documentation index at: https://docs.gravitypay.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Criar cobrança

> Cria uma cobrança avulsa e devolve uma `checkoutUrl` para o cliente pagar. O `postbackSecret` (que valida os webhooks desta cobrança) é retornado **apenas** nesta resposta de criação.



## OpenAPI

````yaml /openapi.json post /v1/charges
openapi: 3.1.0
info:
  title: Gravity Play API
  version: 1.0.0
  description: API para criar cobranças e receber pagamentos.
servers:
  - url: https://api.sandbox.gravitypay.app
    description: Sandbox (testes) — alvo do try-it
  - url: https://api.gravitypay.app
    description: Produção
security:
  - bearerAuth: []
paths:
  /v1/charges:
    post:
      summary: Criar cobrança
      description: >-
        Cria uma cobrança avulsa e devolve uma `checkoutUrl` para o cliente
        pagar. O `postbackSecret` (que valida os webhooks desta cobrança) é
        retornado **apenas** nesta resposta de criação.
      operationId: createCharge
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateChargeRequest'
      responses:
        '201':
          description: Cobrança criada
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Charge'
        '400':
          $ref: '#/components/responses/Error'
        '401':
          $ref: '#/components/responses/Error'
components:
  schemas:
    CreateChargeRequest:
      type: object
      required:
        - currency
      properties:
        currency:
          type: string
          minLength: 3
          maxLength: 3
        items:
          type: array
          items:
            $ref: '#/components/schemas/ChargeItem'
        amountInCents:
          type: integer
          minimum: 1
        customer:
          type: object
          properties:
            email:
              type: string
              format: email
            name:
              type: string
        description:
          type: string
          maxLength: 255
        metadata:
          type: object
          additionalProperties: true
        postbackUrl:
          type: string
          format: uri
        successUrl:
          type: string
          format: uri
        cancelUrl:
          type: string
          format: uri
    Charge:
      type: object
      properties:
        id:
          type: string
          example: chg_2e59538f...
        object:
          type: string
          example: charge
        status:
          type: string
          enum:
            - pending
            - paid
            - failed
            - refunded
            - canceled
        amountInCents:
          type: integer
        currency:
          type: string
        items:
          type: array
          items:
            $ref: '#/components/schemas/ChargeItem'
        description:
          type: string
          nullable: true
        customer:
          type: object
          properties:
            email:
              type: string
              nullable: true
            name:
              type: string
              nullable: true
        metadata:
          type: object
          additionalProperties: true
        checkoutUrl:
          type: string
        postbackSecret:
          type: string
          description: Retornado apenas na criação.
        createdAt:
          type: string
          format: date-time
    ChargeItem:
      type: object
      required:
        - name
        - quantity
        - unitAmountInCents
      properties:
        name:
          type: string
        quantity:
          type: integer
          minimum: 1
        unitAmountInCents:
          type: integer
          minimum: 0
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            type:
              type: string
            message:
              type: string
            param:
              type: string
  responses:
    Error:
      description: Erro
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````