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

# Add or update gateway credentials

> Creates or updates credentials for one or more gateways scoped to the authenticated company. When `use_as_subaccount` is true the gateway creates a recipient sub-account and stores the resulting recipient ID as the secret key.



## OpenAPI

````yaml /api-reference/openapi.json put /api/v1/company/gateways
openapi: 3.0.0
info:
  title: PlugToPay API
  description: API to make payments easy in multiple gateways.
  version: 1.0.0
servers:
  - url: http://localhost:7701
    description: Test Server
security: []
paths:
  /api/v1/company/gateways:
    put:
      tags:
        - Company Gateways
      summary: Add or update gateway credentials
      description: >-
        Creates or updates credentials for one or more gateways scoped to the
        authenticated company. When `use_as_subaccount` is true the gateway
        creates a recipient sub-account and stores the resulting recipient ID as
        the secret key.
      operationId: 98e451b6d03f27c9d1d8c5cfcb514700
      parameters:
        - $ref: '#/components/parameters/XClientId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              required:
                - gateways
              properties:
                gateways:
                  type: array
                  items:
                    required:
                      - gateway_slug
                      - secret_key
                    properties:
                      gateway_slug:
                        type: string
                        enum:
                          - pagarme
                          - picpay
                          - safe2pay
                          - pagbank
                          - stripe
                        example: pagarme
                      secret_key:
                        type: string
                        maxLength: 500
                        example: sk_live_abc123
                      order:
                        description: >-
                          Priority order for gateway selection. Auto-assigned
                          sequentially if omitted.
                        type: integer
                        minimum: 1
                        example: 1
                        nullable: true
                      client_id:
                        type: string
                        maxLength: 255
                        example: client_xyz
                        nullable: true
                      use_as_subaccount:
                        description: >-
                          When true, registers a recipient sub-account via the
                          gateway. `subaccount_information` is required in this
                          case.
                        type: boolean
                        example: false
                        nullable: true
                      subaccount_information:
                        description: Required when use_as_subaccount is true.
                        properties:
                          name:
                            type: string
                            maxLength: 255
                            example: Maria Silva
                          trading_name:
                            type: string
                            maxLength: 255
                            example: Loja da Maria
                          email:
                            type: string
                            format: email
                            maxLength: 255
                            example: maria@example.com
                          document:
                            description: CPF (individual) or CNPJ (corporation).
                            type: string
                            example: 123.456.789-00
                          type:
                            type: string
                            enum:
                              - individual
                              - corporation
                            example: individual
                          annual_revenue:
                            description: Required for corporation. Amount in cents.
                            type: integer
                            example: 120000
                            nullable: true
                          company_type:
                            description: >-
                              Legal company type (LTDA, ME, etc.). Corporation
                              only.
                            type: string
                            maxLength: 15
                            example: LTDA
                            nullable: true
                          birthdate:
                            description: Required for individual (Y-m-d).
                            type: string
                            format: date
                            example: '1990-06-15'
                            nullable: true
                          monthly_income:
                            description: Required for individual. Amount in cents.
                            type: integer
                            example: 500000
                            nullable: true
                          professional_occupation:
                            description: Required for individual.
                            type: string
                            maxLength: 255
                            example: Software Engineer
                            nullable: true
                          phone_numbers:
                            type: array
                            items:
                              required:
                                - country
                                - number
                                - type
                              properties:
                                country:
                                  type: string
                                  maxLength: 2
                                  minLength: 2
                                  example: BR
                                number:
                                  type: string
                                  maxLength: 9
                                  minLength: 9
                                  example: '999999999'
                                type:
                                  type: string
                                  maxLength: 15
                                  example: mobile
                              type: object
                            nullable: true
                          address:
                            description: Required for both individual and corporation.
                            required:
                              - street
                              - complementary
                              - number
                              - neighborhood
                              - city
                              - state
                              - zip_code
                            properties:
                              street:
                                type: string
                                maxLength: 255
                                example: Rua das Flores
                              complementary:
                                type: string
                                maxLength: 255
                                example: Apto 101
                              number:
                                type: string
                                maxLength: 6
                                example: '123'
                              neighborhood:
                                type: string
                                maxLength: 80
                                example: Centro
                              city:
                                type: string
                                maxLength: 80
                                example: São Paulo
                              state:
                                type: string
                                maxLength: 3
                                example: SP
                              zip_code:
                                type: string
                                maxLength: 9
                                example: 01310-100
                            type: object
                            nullable: true
                          default_bank_account:
                            description: Required when subaccount_information is provided.
                            required:
                              - holder_name
                              - holder_type
                              - holder_document
                              - bank_code
                              - branch_number
                              - account_number
                              - account_check_digit
                              - type
                            properties:
                              holder_name:
                                type: string
                                maxLength: 255
                                example: Maria Silva
                              holder_type:
                                type: string
                                enum:
                                  - individual
                                  - company
                                example: individual
                              holder_document:
                                type: string
                                example: 123.456.789-00
                              bank_code:
                                type: string
                                example: '341'
                              branch_number:
                                description: Agency number.
                                type: string
                                example: '0001'
                              account_number:
                                type: string
                                maxLength: 13
                                example: '12345678'
                              account_check_digit:
                                type: string
                                example: '9'
                              type:
                                type: string
                                enum:
                                  - checking
                                  - savings
                                example: checking
                            type: object
                            nullable: true
                          managing_partners:
                            description: >-
                              Required for corporation. Legal representatives of
                              the company.
                            type: array
                            items:
                              required:
                                - name
                                - email
                                - document
                                - birthdate
                                - monthly_income
                                - professional_occupation
                                - self_declared_legal_representative
                                - address
                                - phone_numbers
                              properties:
                                name:
                                  type: string
                                  maxLength: 200
                                  example: João Souza
                                email:
                                  type: string
                                  format: email
                                  maxLength: 255
                                  example: joao@example.com
                                document:
                                  description: CPF of the partner.
                                  type: string
                                  example: 987.654.321-00
                                birthdate:
                                  description: Y-m-d format.
                                  type: string
                                  format: date
                                  example: '1985-03-20'
                                monthly_income:
                                  description: Amount in cents.
                                  type: integer
                                  minimum: 0
                                  example: 300000
                                professional_occupation:
                                  type: string
                                  maxLength: 255
                                  example: Director
                                self_declared_legal_representative:
                                  type: boolean
                                  example: true
                                address:
                                  required:
                                    - street
                                    - complementary
                                    - street_number
                                    - neighborhood
                                    - city
                                    - state
                                    - zip_code
                                    - reference_point
                                  properties:
                                    street:
                                      type: string
                                      maxLength: 255
                                      example: Av. Paulista
                                    complementary:
                                      type: string
                                      maxLength: 255
                                      example: Sala 5
                                    street_number:
                                      type: string
                                      maxLength: 6
                                      example: '1000'
                                    neighborhood:
                                      type: string
                                      maxLength: 80
                                      example: Bela Vista
                                    city:
                                      type: string
                                      maxLength: 80
                                      example: São Paulo
                                    state:
                                      type: string
                                      maxLength: 3
                                      example: SP
                                    zip_code:
                                      type: string
                                      maxLength: 8
                                      minLength: 8
                                      example: '01311100'
                                    reference_point:
                                      type: string
                                      maxLength: 255
                                      example: Próximo ao metrô
                                  type: object
                                phone_numbers:
                                  type: array
                                  items:
                                    required:
                                      - ddd
                                      - number
                                    properties:
                                      ddd:
                                        type: string
                                        maxLength: 2
                                        minLength: 2
                                        example: '11'
                                      number:
                                        type: string
                                        maxLength: 9
                                        example: '999999999'
                                    type: object
                              type: object
                            nullable: true
                        type: object
                        nullable: true
                    type: object
              type: object
      responses:
        '200':
          description: Gateway credentials saved
          content:
            application/json:
              schema:
                properties:
                  data:
                    type: array
                    items:
                      properties:
                        id:
                          type: integer
                          example: 1
                        company_id:
                          type: integer
                          example: 42
                        gateway_id:
                          type: integer
                          example: 1
                        gateway_slug:
                          type: string
                          example: pagarme
                        client_id:
                          type: string
                          example: null
                          nullable: true
                        created_at:
                          type: string
                          format: date-time
                          example: '2024-01-15T10:30:00Z'
                        updated_at:
                          type: string
                          format: date-time
                          example: '2024-01-15T10:30:00Z'
                      type: object
                type: object
        '401':
          description: Unauthorized — Invalid API Key
        '404':
          description: One or more gateways not found or inactive
        '422':
          description: Validation Error
      security:
        - ApiKeyAuth: []
components:
  parameters:
    XClientId:
      name: x-client-id
      in: header
      description: Client identifier for the company in the request.
      required: true
      schema:
        type: string
        example: client_abc123
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      description: Company API key. Send in the X-API-Key header.
      name: X-API-Key
      in: header

````