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

# Criar assinatura recorrente

> Plano com cobrança automática em ciclo fixo (semanal, mensal, etc.). Não é cobrança avulsa.

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST 'https://api.goatpay.com.br/v1/subscriptions/create' \
    -H 'X-API-Key: gp_live_SUA_CHAVE' \
    -H 'Content-Type: application/json' \
    -d '{ "salesCustomerId": "clx_customer", "billingType": "BOLETO", "value": 99.9, "cycle": "MONTHLY", "nextDueDate": "2026-08-01", "description": "Plano Premium" }'
  ```
</RequestExample>

<ResponseExample>
  ```json Success theme={null}
  {
    "success": true,
    "message": "Assinatura criada",
    "data": {
      "id": "clx_sub",
      "providerSubscriptionId": "sub_ext_xyz",
      "status": "ACTIVE",
      "cycle": "MONTHLY",
      "billingType": "BOLETO",
      "value": 99.9,
      "description": "Plano Premium",
      "nextDueDate": "2026-08-01T00:00:00.000Z",
      "createdAt": "2026-07-01T12:00:00.000Z",
      "customer": {
        "id": "clx_customer",
        "name": "Maria Silva",
        "taxId": "12345678909"
      },
      "plan": {
        "id": "clx_plan",
        "name": "Plano Premium"
      }
    },
    "requestId": "req_abc123"
  }
  ```
</ResponseExample>

### Corpo da requisição

<ParamField body="salesCustomerId" type="string" required>
  ID do cliente cadastrado (`POST /customers/create`).
</ParamField>

<ParamField body="billingType" type="string">
  BOLETO, CREDIT\_CARD, DEBIT\_CARD ou VOUCHER.
</ParamField>

<ParamField body="value" type="number">
  Valor de cada ciclo em reais.
</ParamField>

<ParamField body="cycle" type="string">
  WEEKLY, MONTHLY, QUARTERLY, SEMIANNUALLY, YEARLY, etc.
</ParamField>

<ParamField body="nextDueDate" type="string" required>
  Primeiro vencimento (YYYY-MM-DD).
</ParamField>

<ParamField body="planId" type="string">
  ID do plano cadastrado.
</ParamField>

<ParamField body="description" type="string">
  Descrição da assinatura.
</ParamField>

<ParamField body="creditCardToken" type="string">
  Token do cartão quando `billingType` é CREDIT\_CARD.
</ParamField>

<Note>
  Recorrência com ciclo fixo. Para pagamento **único** use `POST /billings/create`. Confirme renovações via webhooks.
</Note>


## OpenAPI

````yaml POST /subscriptions/create
openapi: 3.1.0
info:
  title: GoatPay API
  description: >
    API pública merchant da GoatPay. Autenticação via header `X-API-Key:
    gp_live_...`.

    Respostas de sucesso usam o envelope `{ success, message, data, requestId
    }`.

    Campos internos (`accountId`, `metadata`, histórico de entregas de webhook,
    etc.) não são expostos.

    `providerTransactionId` aparece como `referenceId`; `providerInfractionId`
    como `infractionId`.

    Rate limit global: 100 requisições por minuto por API key (HTTP 429). Sem
    chave, limite por IP.
  version: 1.0.0
servers:
  - url: https://api.goatpay.com.br/v1
    description: Produção
security:
  - apiKeyAuth: []
tags:
  - name: pix
    description: >-
      Cobranças PIX (receber), reembolsos de depósito recebido e transferências
      PIX (enviar). Alias legado em payouts/* para envios.
  - name: transfer-internal
    description: Transferências entre contas GoatPay
  - name: transfer-scheduled
    description: Transferências programadas (agendar, repetir ou por saldo)
  - name: crypto
    description: Depósitos e transferências em criptomoeda
  - name: billings
    description: >-
      Cobranças avulsas (pagamento único) — boleto, cartão ou PIX na Conta
      Padrão (PF ou PJ)
  - name: subscriptions
    description: >-
      Assinaturas recorrentes com ciclo fixo — boleto, cartão ou PIX na Conta
      Padrão (PF ou PJ)
  - name: account
    description: Saldo e extrato
  - name: subaccount
    description: Subcontas merchant (carteiras lógicas sob a conta principal)
  - name: meds
    description: Disputas MED
  - name: webhooks
    description: Endpoints de webhook de saída
  - name: payouts
    description: Alias de transfer-pix para saques PIX
  - name: customers
    description: Clientes da loja (CRM)
  - name: products
    description: Produtos e entregas digitais
  - name: coupons
    description: Cupons de desconto para links
  - name: payment-links
    description: Links de pagamento e checkout hospedado
paths:
  /subscriptions/create:
    post:
      tags:
        - subscriptions
      summary: Criar assinatura recorrente
      description: >-
        Plano com cobrança automática em ciclo fixo. Para pagamento único use
        `/billings/create`.
      operationId: createSubscription
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateSubscription'
      responses:
        '200':
          $ref: '#/components/responses/SuccessEnvelope'
        '403':
          $ref: '#/components/responses/Forbidden'
components:
  schemas:
    CreateSubscription:
      type: object
      required:
        - method
        - amount
        - cycle
        - nextDueDate
        - customer
      properties:
        method:
          type: string
          enum:
            - BOLETO
            - CARD_CREDIT
            - PIX
        amount:
          type: number
          minimum: 0.01
        cycle:
          type: string
          enum:
            - WEEKLY
            - BIWEEKLY
            - MONTHLY
            - BIMONTHLY
            - QUARTERLY
            - SEMIANNUALLY
            - YEARLY
        nextDueDate:
          type: string
          format: date
        customer:
          $ref: '#/components/schemas/PublicCustomer'
        description:
          type: string
        cardToken:
          type: string
          description: Token de cartão (cobranças seguintes)
        creditCard:
          $ref: '#/components/schemas/CreditCard'
        creditCardHolderInfo:
          $ref: '#/components/schemas/CreditCardHolderInfo'
        remoteIp:
          type: string
          description: IP do comprador (obrigatório em CARD_CREDIT)
        authorizeOnly:
          type: boolean
    PublicCustomer:
      type: object
      required:
        - name
        - taxId
      properties:
        id:
          type: string
          description: ID no seu sistema (default taxId)
        name:
          type: string
        taxId:
          type: string
          description: CPF/CNPJ somente dígitos
        email:
          type: string
          format: email
        phone:
          type: string
    CreditCard:
      type: object
      required:
        - holderName
        - number
        - expiryMonth
        - expiryYear
        - ccv
      properties:
        holderName:
          type: string
        number:
          type: string
        expiryMonth:
          type: string
        expiryYear:
          type: string
        ccv:
          type: string
    CreditCardHolderInfo:
      type: object
      required:
        - name
        - email
        - cpfCnpj
        - postalCode
        - addressNumber
        - phone
      properties:
        name:
          type: string
        email:
          type: string
          format: email
        cpfCnpj:
          type: string
        postalCode:
          type: string
        addressNumber:
          type: string
        addressComplement:
          type: string
        phone:
          type: string
        mobilePhone:
          type: string
    SuccessEnvelope:
      type: object
      required:
        - success
        - message
        - data
      properties:
        success:
          type: boolean
          example: true
        message:
          type: string
          example: Operação concluída com sucesso
        data:
          type: object
          additionalProperties: true
        requestId:
          type: string
    ErrorEnvelope:
      type: object
      required:
        - success
        - message
        - error
      properties:
        success:
          type: boolean
          example: false
        message:
          type: string
          example: Subconta inativa
        error:
          type: object
          properties:
            code:
              type: string
              example: Bad Request
            statusCode:
              type: integer
              example: 400
        requestId:
          type: string
          example: req_abc123
  responses:
    SuccessEnvelope:
      description: Operação concluída.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/SuccessEnvelope'
          examples:
            default:
              summary: Sucesso
              value:
                success: true
                message: Operação concluída com sucesso
                data: {}
                requestId: req_abc123
    Forbidden:
      description: Chave sem permissão para este endpoint.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key
      description: Chave `gp_live_...` criada em Integrações → Chaves de API no dashboard.

````