> ## 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.

# Regenerar client secret

> Invalida o secret anterior e retorna um novo client secret.

Permissão: `oauth-apps/clients/regenerate-secret`.

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST 'https://api.goatpay.com.br/v1/oauth-apps/clients/regenerate-secret/clx_app_01/PRODUCTION' \
    -H 'X-API-Key: gp_live_SUA_CHAVE'
  ```
</RequestExample>

<ResponseExample>
  ```json Success theme={null}
  {
    "success": true,
    "message": "Client secret regenerado com sucesso",
    "data": {
      "client": {
        "id": "clx_client_prod",
        "environment": "PRODUCTION",
        "clientId": "gp_oauth_live_x9y8z7...",
        "clientSecretPreview": "gp_oauth_live_...****",
        "status": "ACTIVE",
        "redirectUris": [
          { "id": "clx_uri_2", "uri": "https://sua-app.com/oauth/callback" }
        ]
      },
      "clientSecret": "gp_oauth_live_NOVO_SECRET_AQUI"
    },
    "requestId": "req_oauth_regen"
  }
  ```
</ResponseExample>

### Parâmetros

<ParamField path="applicationId" type="string" required>
  ID da aplicação OAuth.
</ParamField>

<ParamField path="environment" type="string" required>
  `DEV` ou `PRODUCTION`.
</ParamField>

<Warning>
  O secret anterior deixa de funcionar imediatamente em [POST /oauth/token](/api-reference/endpoint/oauth/token).
</Warning>


## OpenAPI

````yaml POST /oauth-apps/clients/regenerate-secret/{applicationId}/{environment}
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: oauth
    description: OAuth 2.0 — autorização de terceiros (fora do prefixo /v1)
  - name: oauth-apps
    description: Gestão de aplicações OAuth (prefixo /v1, API key)
  - 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:
  /oauth-apps/clients/regenerate-secret/{applicationId}/{environment}:
    post:
      tags:
        - oauth-apps
      summary: Regenerar client secret
      description: >-
        Invalida secret anterior e retorna novo. Permissão
        `oauth-apps/clients/regenerate-secret`.
      operationId: oauthAppsClientsRegenerateSecret
      parameters:
        - name: applicationId
          in: path
          required: true
          schema:
            type: string
        - name: environment
          in: path
          required: true
          schema:
            type: string
            enum:
              - DEV
              - PRODUCTION
      responses:
        '200':
          $ref: '#/components/responses/OAuthAppsEnsureClientSuccess'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
components:
  responses:
    OAuthAppsEnsureClientSuccess:
      description: Client OAuth criado ou consultado.
      content:
        application/json:
          schema:
            type: object
            required:
              - success
              - message
              - data
            properties:
              success:
                type: boolean
              message:
                type: string
              data:
                $ref: '#/components/schemas/PublicOAuth2EnsureClientData'
              requestId:
                type: string
    Unauthorized:
      description: Chave ausente, inválida ou revogada.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
    Forbidden:
      description: Chave sem permissão para este endpoint.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
    NotFound:
      description: Recurso não encontrado.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
  schemas:
    PublicOAuth2EnsureClientData:
      type: object
      properties:
        client:
          $ref: '#/components/schemas/PublicOAuth2Client'
        clientSecret:
          type: string
          nullable: true
          description: Preenchido na criação ou regeneração; null se o client já existia.
    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
    PublicOAuth2Client:
      type: object
      properties:
        id:
          type: string
        environment:
          type: string
          enum:
            - DEV
            - PRODUCTION
        clientId:
          type: string
          example: gp_oauth_dev_...
        clientSecretPreview:
          type: string
          example: gp_oauth_dev_...****
        status:
          type: string
        redirectUris:
          type: array
          items:
            $ref: '#/components/schemas/PublicOAuth2RedirectUri'
    PublicOAuth2RedirectUri:
      type: object
      properties:
        id:
          type: string
        uri:
          type: string
          format: uri
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key
      description: Chave `gp_live_...` criada em Integrações → Chaves de API no dashboard.

````