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

# Criar link de pagamento

> Cria um link ativo (`status: approved`), com a página em `https://app.nasten.com.br/checkoutPayment/{id}`.
Link criado com a chave de teste é real e cobra de verdade.




## OpenAPI

````yaml /openapi.yaml post /v1/payment-links
openapi: 3.1.0
info:
  title: API Nasten
  version: '1.0'
  description: >
    API de pagamentos da Nasten: Pix, cartão, boleto, saques, clientes,

    produtos, links de pagamento, assinaturas e webhooks.


    **Autenticação.** Chame `POST /auth` com Basic
    (`base64(chave_publica:chave_secreta)`)

    para obter o Bearer token usado em todas as rotas `/v1/*`. O token vale 10
    minutos.


    **Valores.** Todo valor monetário é um inteiro em centavos.


    **Modo de teste.** O host é o mesmo. Com a chave de Desenvolvimento, as
    cobranças

    viram vendas de teste, sem dinheiro de verdade. Veja `POST
    /v1/sandbox/transactions/{transactionId}/pay`.


    **Erros.** O corpo padrão é `{ "success": false, "message": "...", "code":
    "NST-<status>-<hash>" }`.

    Erro de validação traz também `errors`. O `403` traz `error` e, quando há,
    `reason`.

    O `429` traz `error`, `retryAfterMs`, `limit`, `window` e o header
    `Retry-After`.

    Algumas rotas devolvem só `success` e `message`, como indicado em cada uma.

    Qualquer rota pode responder `503` em sobrecarga temporária (`Service
    temporarily unavailable. Please retry.`).


    **Limites.** `POST /auth`: 200 requisições por minuto por chave pública.

    Demais rotas: 1800 requisições por minuto por empresa.
  contact:
    name: Suporte Nasten
    email: tech@nasten.com.br
servers:
  - url: https://api.nasten.net
    description: Produção e modo de teste (o ambiente é definido pela chave)
security:
  - bearerAuth: []
tags:
  - name: Autenticação
  - name: Pix In
  - name: Cartão
  - name: Boleto
  - name: Modo de teste
  - name: Transações
  - name: Pix Out
  - name: Financeiro
  - name: Clientes
  - name: Produtos
  - name: Links de Pagamento
  - name: Assinaturas
  - name: Webhooks
paths:
  /v1/payment-links:
    post:
      tags:
        - Links de Pagamento
      summary: Criar link de pagamento
      description: >
        Cria um link ativo (`status: approved`), com a página em
        `https://app.nasten.com.br/checkoutPayment/{id}`.

        Link criado com a chave de teste é real e cobra de verdade.
      operationId: criarLink
      requestBody:
        required: true
        content:
          application/json:
            schema:
              allOf:
                - type: object
                  required:
                    - name
                  properties:
                    name:
                      type: string
                      minLength: 1
                      maxLength: 255
                      description: Nome do link (espaços nas pontas são removidos)
                      example: Pedido 1042
                    amount:
                      type: integer
                      minimum: 0
                      default: 0
                      description: >-
                        Centavos. Pagamento único e assinatura exigem mais que
                        zero. No link grátis, 0 ou ausente. Na assinatura, preço
                        de cada cobrança.
                      example: 50000
                    paymentMethods:
                      type: array
                      uniqueItems: true
                      default: []
                      description: >-
                        Pagamento único exige ao menos uma. Assinatura exige
                        exatamente credit_card. Link grátis fica vazio. Toda
                        forma precisa estar liberada para a conta.
                      items:
                        $ref: '#/components/schemas/FormaDoLink'
                      example:
                        - pix
                        - credit_card
                    returnUrl:
                      type: string
                      format: uri
                      description: >-
                        Para onde o comprador vai depois de pagar. Texto vazio
                        vale como ausente. Só redireciona, não recebe eventos.
                    imageUrl:
                      type:
                        - string
                        - 'null'
                      maxLength: 2048
                      description: >-
                        Imagem do checkout, gravada como veio. Vazio ou null
                        vale sem imagem.
                    interestPassthrough:
                      type: boolean
                      default: false
                      description: 'true: o comprador paga os juros do parcelamento'
                    allowedDoubleCard:
                      type: boolean
                      default: false
                      description: >-
                        Libera dois cartões. Sem credit_card na lista vira
                        false. Não vale na assinatura.
                    allowedCardPix:
                      type: boolean
                      default: false
                      description: >-
                        Libera Cartão + Pix. Sem credit_card e pix na lista vira
                        false. Não vale na assinatura.
                - $ref: '#/components/schemas/CamposDoCheckoutDoLink'
                - $ref: '#/components/schemas/CamposDePrecoDoLink'
            example:
              name: Pedido 1042
              amount: 50000
              paymentMethods:
                - pix
                - credit_card
              allowedDoubleCard: true
              externalReference: pedido-1042
              returnUrl: https://seusite.com.br/obrigado?pedido=1042
      responses:
        '201':
          description: Link criado, sem `companyId`
          content:
            application/json:
              schema:
                type: object
                required:
                  - success
                  - data
                properties:
                  success:
                    type: boolean
                    const: true
                  data:
                    $ref: '#/components/schemas/LinkDePagamento'
        '400':
          description: >-
            Campo fora do formato (com `errors`), regras do tipo de preço,
            perguntas com id repetido, forma não liberada ou produto recusado ou
            banido.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErroDeValidacao'
        '401':
          $ref: '#/components/responses/NaoAutenticado'
        '404':
          description: >-
            `Produto não encontrado nesta empresa`: productId inexistente,
            apagado ou de outra empresa.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Erro'
        '413':
          $ref: '#/components/responses/CorpoGrandeDemais'
        '415':
          $ref: '#/components/responses/TipoDeConteudoInvalido'
        '429':
          $ref: '#/components/responses/LimiteExcedido'
        '500':
          $ref: '#/components/responses/ErroInterno'
components:
  schemas:
    FormaDoLink:
      type: string
      enum:
        - pix
        - credit_card
        - boleto
        - google_pay
        - apple_pay
        - samsung_pay
    CamposDoCheckoutDoLink:
      type: object
      properties:
        externalReference:
          type:
            - string
            - 'null'
          maxLength: 255
          description: >-
            Referência sua, devolvida em paymentLink.externalReference de cada
            venda. Vazio ou null apaga.
          example: pedido-1042
        productId:
          type:
            - string
            - 'null'
          description: >-
            Produto da sua empresa ligado ao link (cuid). Não pode estar
            apagado, recusado nem banido. Vazio ou null desliga.
        title:
          type:
            - string
            - 'null'
          maxLength: 120
          description: Título do checkout. Vazio usa o name.
        description:
          type:
            - string
            - 'null'
          maxLength: 80
          description: Texto curto abaixo do título
        checkoutStyle:
          anyOf:
            - $ref: '#/components/schemas/EstiloDoCheckout'
            - type: 'null'
    CamposDePrecoDoLink:
      type: object
      properties:
        pricingType:
          type: string
          enum:
            - one_time
            - recurring
            - free
          default: one_time
        recurringInterval:
          type:
            - string
            - 'null'
          enum:
            - weekly
            - monthly
            - bimonthly
            - quarterly
            - semiannual
            - annual
            - null
          description: Só assinatura, e obrigatório nela
        initialFee:
          type:
            - integer
            - 'null'
          minimum: 1
          description: Só assinatura. Taxa em centavos somada à primeira cobrança.
        trialDays:
          type:
            - integer
            - 'null'
          minimum: 1
          maximum: 365
          description: Só assinatura. Exige initialFee.
        maxCharges:
          type:
            - integer
            - 'null'
          minimum: 2
          maximum: 360
          description: Só assinatura. Sem o campo, cobra até ser cancelada.
        cancelDiscountPercent:
          type:
            - integer
            - 'null'
          minimum: 1
          maximum: 100
          description: Só assinatura. Vai junto com cancelDiscountIntervals.
        cancelDiscountIntervals:
          type:
            - integer
            - 'null'
          minimum: 0
          maximum: 120
          description: 'Só assinatura. Em quantas cobranças o desconto vale. 0: para sempre.'
        accessDays:
          type:
            - integer
            - 'null'
          minimum: 1
          maximum: 3650
          description: Só link grátis. Quantos dias o acesso dura.
        waitlistEnabled:
          type: boolean
          default: false
          description: Liga a lista de espera
        questions:
          type:
            - array
            - 'null'
          maxItems: 10
          items:
            $ref: '#/components/schemas/PerguntaDoLinkEntrada'
    LinkDePagamento:
      allOf:
        - $ref: '#/components/schemas/LinkDePagamentoResumo'
        - type: object
          properties:
            returnUrl:
              type:
                - string
                - 'null'
              format: uri
            updatedAt:
              type: string
              format: date-time
            interestPassthrough:
              type: boolean
            allowedDoubleCard:
              type: boolean
            allowedCardPix:
              type: boolean
    ErroDeValidacao:
      allOf:
        - $ref: '#/components/schemas/Erro'
        - type: object
          properties:
            errors:
              type: array
              description: Detalhe campo a campo, quando a falha é de validação
              items:
                type: object
                properties:
                  path:
                    type: string
                    example: customer.document
                  message:
                    type: string
                    example: Documento inválido
    Erro:
      type: object
      required:
        - success
        - message
        - code
      properties:
        success:
          type: boolean
          const: false
        message:
          type: string
          description: Descrição do problema. Algumas mensagens vêm em inglês.
          example: Descrição do erro
        code:
          type: string
          description: >-
            Código no formato NST-<status>-<hash>. Identifica a rota e o status,
            não a chamada. Cite ao acionar o suporte.
          example: NST-400-3f7a
    EstiloDoCheckout:
      type: object
      additionalProperties: false
      description: Aparência do checkout. Chave desconhecida responde 400.
      properties:
        backgroundColor:
          type: string
          pattern: ^#[0-9A-Fa-f]{6}$
          example: '#FFFFFF'
        buttonColor:
          type: string
          pattern: ^#[0-9A-Fa-f]{6}$
          example: '#E70000'
        fontFamily:
          type: string
          minLength: 1
          maxLength: 60
          pattern: ^[A-Za-z0-9 ]+$
          description: Nome como aparece no Google Fonts
          example: Inter
        borderStyle:
          type: string
          enum:
            - rounded
            - pill
            - rectangular
    PerguntaDoLinkEntrada:
      type: object
      additionalProperties: false
      required:
        - title
      properties:
        id:
          type: string
          minLength: 1
          maxLength: 40
          description: Sem ele, a Nasten gera um. Dois iguais respondem 400.
        title:
          type: string
          minLength: 1
          maxLength: 120
          example: Qual é o seu Instagram?
        placeholder:
          type:
            - string
            - 'null'
          maxLength: 120
          example: '@seuperfil'
        optional:
          type: boolean
          default: false
    LinkDePagamentoResumo:
      type: object
      properties:
        id:
          type: string
          example: clpaylink1234567890abcdef
        name:
          type: string
          example: Pedido 1042
        imageUrl:
          type:
            - string
            - 'null'
        createdAt:
          type: string
          format: date-time
        paymentMethods:
          type: array
          items:
            $ref: '#/components/schemas/FormaDoLink'
        amount:
          type: integer
          description: >-
            Centavos. 0 no link grátis. Na assinatura, o preço de cada
            renovação.
          example: 50000
        status:
          type: string
          enum:
            - approved
            - cancelled
        productId:
          type:
            - string
            - 'null'
        title:
          type:
            - string
            - 'null'
        description:
          type:
            - string
            - 'null'
        checkoutStyle:
          anyOf:
            - $ref: '#/components/schemas/EstiloDoCheckout'
            - type: 'null'
        product:
          type:
            - object
            - 'null'
          properties:
            id:
              type: string
            name:
              type: string
            imageUrl:
              type:
                - string
                - 'null'
        externalReference:
          type:
            - string
            - 'null'
          example: pedido-1042
        pricingType:
          type: string
          enum:
            - free
            - one_time
            - recurring
        recurringInterval:
          type:
            - string
            - 'null'
          enum:
            - weekly
            - monthly
            - bimonthly
            - quarterly
            - semiannual
            - annual
            - null
        initialFee:
          type:
            - integer
            - 'null'
        trialDays:
          type:
            - integer
            - 'null'
        maxCharges:
          type:
            - integer
            - 'null'
        cancelDiscountPercent:
          type:
            - integer
            - 'null'
        cancelDiscountIntervals:
          type:
            - integer
            - 'null'
        accessDays:
          type:
            - integer
            - 'null'
        waitlistEnabled:
          type: boolean
        questions:
          type: array
          items:
            $ref: '#/components/schemas/PerguntaDoLink'
    ErroDeLimite:
      allOf:
        - $ref: '#/components/schemas/Erro'
        - type: object
          properties:
            error:
              type: string
              const: Too Many Requests
            retryAfterMs:
              type: integer
              description: Milissegundos até poder repetir
              example: 42000
            limit:
              type: integer
              description: Limite da janela
              example: 1800
            window:
              type: string
              description: Tamanho da janela por extenso em inglês
              example: 1 minute
    PerguntaDoLink:
      type: object
      properties:
        id:
          type: string
        title:
          type: string
        placeholder:
          type:
            - string
            - 'null'
        optional:
          type: boolean
  responses:
    NaoAutenticado:
      description: >
        Token ausente, malformado ou expirado (`Token inválido ou expirado`), ou
        token sem sessão válida (`Token expired or invalid`).

        Gere outro token em POST /auth e repita.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Erro'
          example:
            success: false
            message: Token inválido ou expirado
            code: NST-401-rcp9
    CorpoGrandeDemais:
      description: '`O corpo da requisição passa do tamanho máximo aceito.`'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Erro'
    TipoDeConteudoInvalido:
      description: '`Content-Type não aceito. Envie o corpo como application/json.`'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Erro'
    LimiteExcedido:
      description: >-
        Limite de requisições excedido (1800 por minuto por empresa nas rotas
        /v1/*, 200 por minuto por chave em /auth).
      headers:
        Retry-After:
          description: Segundos até poder repetir
          schema:
            type: integer
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErroDeLimite'
    ErroInterno:
      description: >-
        Falha inesperada (`Internal server error`) ou resposta que não passou na
        conferência do servidor. Repita com backoff e, persistindo, envie o
        `code` ao suporte.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Erro'
          example:
            success: false
            message: Internal server error
            code: NST-500-9e2b
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: Token obtido em POST /auth. Vale 10 minutos.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.