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

# Create a key

> Creates a key with the permissions given, never more than the calling key holds, and never `apiKey:write`. The owners of the organization are e-mailed. Needs `apiKey:write`.



## OpenAPI

````yaml POST /developer/v1/api-key
openapi: 3.1.0
info:
  title: Compago API
  version: 1.0.0
  description: >-
    Public and private API endpoints for Compago's payment infrastructure. This
    specification currently includes endpoints for one-time payments. More
    endpoints will be added as the platform evolves.
servers:
  - url: https://demo-api-harmony.compago.com/api
  - url: https://api-harmony.compago.com/api
security: []
tags:
  - name: OneTimePayment
    description: Endpoints for creating and processing one-time payment links
  - name: PaymentMethod
    description: >-
      Endpoints for saving cards, charging saved payment methods, holding and
      capturing funds, and processing refunds
  - name: PaymentIntent
    description: >-
      Endpoints for creating and managing card-present payment intents for POS
      terminal integrations
  - name: Payments
    description: Read the payments your organization has taken
  - name: Subscriptions
    description: Read and manage recurring billing agreements
  - name: PaymentLinks
    description: Create, edit and retire hosted checkout links
  - name: Products
    description: Manage the catalogue behind product-based payment links
  - name: Promotions
    description: Read the promotions your organization funds or benefits from
  - name: Salespeople
    description: Read the point-of-sale operators in your organization
  - name: Organization
    description: Read your organization profile and its members
  - name: SavedCards
    description: Read saved payment methods and their payments
  - name: Payouts
    description: >-
      Read the transfers Compago sent to your bank accounts and what each one
      paid
  - name: Events
    description: >-
      Read the webhook events of the last 30 days, to reconcile after your
      endpoint was down
  - name: ApiKeys
    description: Manage your organization's API keys with a key that holds `apiKey:write`.
paths:
  /developer/v1/api-key:
    post:
      tags:
        - ApiKeys
      summary: Create a key
      description: >-
        Creates a key with the permissions given, never more than the calling
        key holds, and never `apiKey:write`. The owners of the organization are
        e-mailed. Needs `apiKey:write`.
      operationId: createApiKey
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  maxLength: 80
                  description: Where the key is used, e.g. `ERP`.
                permissions:
                  type: array
                  minItems: 1
                  items:
                    $ref: '#/components/schemas/ApiKeyPermission'
                  description: What the key may do. A write brings the reads it needs.
                expiresAt:
                  type:
                    - string
                    - 'null'
                  format: date-time
                  description: >-
                    When the key stops working: between 1 hour and 2 years from
                    now. `null` or omitted: never.
              required:
                - name
                - permissions
            example:
              name: Conciliación
              permissions:
                - payout:read
                - fee:read
              expiresAt: '2027-02-01T00:00:00Z'
      responses:
        '201':
          description: Created. The only response that carries the whole key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicApiKeyWithSecret'
        '400':
          description: Bad request. An unknown permission or an expiry out of range.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicError'
        '401':
          description: >-
            Unauthorized. The key is missing or unknown (`UNAUTHORIZED`),
            expired (`API_KEY_EXPIRED`), turned off (`API_KEY_DISABLED`) or
            revoked (`API_KEY_REVOKED`).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicError'
        '403':
          description: >-
            Forbidden. The key does not hold `apiKey:write`
            (`INSUFFICIENT_SCOPE`), or tried to give permissions it does not
            hold (`SCOPE_NOT_GRANTABLE`).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicError'
        '429':
          description: >-
            Rate limit exceeded. See the `Retry-After` and `X-RateLimit-*`
            headers.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicError'
      security:
        - ApiKeyAuth: []
components:
  schemas:
    ApiKeyPermission:
      type: string
      enum:
        - payment:read
        - refund:write
        - oneTimePayment:read
        - oneTimePayment:write
        - paymentLink:read
        - subscription:read
        - paymentMethod:read
        - paymentMethod:write
        - paymentIntent:read
        - paymentIntent:write
        - terminal:read
        - salesperson:read
        - product:read
        - promotion:read
        - fee:read
        - payout:read
        - bankAccount:read
        - organization:read
        - member:read
        - apiKey:write
      description: >-
        A permission a key can hold. See [Key
        permissions](/get-started/api-key-permissions).
    PublicApiKeyWithSecret:
      allOf:
        - $ref: '#/components/schemas/PublicApiKey'
        - type: object
          properties:
            key:
              type: string
              description: >-
                The whole key, starting with `cmp_`. Shown only in this
                response: store it now.
          required:
            - key
    PublicError:
      type: object
      properties:
        message:
          type: string
          description: Human-readable description.
        code:
          type: string
          description: Stable machine-readable code. Branch on this, not on `message`.
      required:
        - message
    PublicApiKey:
      type: object
      description: >-
        An API key. Never its secret, which only the responses that create or
        rotate a key carry.
      properties:
        id:
          type: string
          format: uuid
        name:
          type:
            - string
            - 'null'
        start:
          type:
            - string
            - 'null'
          description: The first characters of the secret, e.g. `cmp_7Hk2`.
        lastFour:
          type:
            - string
            - 'null'
          description: >-
            The last four characters of the secret. `null` on keys created
            before they were recorded.
        status:
          type: string
          enum:
            - active
            - disabled
            - expired
        fullAccess:
          type: boolean
          description: >-
            `true` for a key created before permissions: it holds every
            permission but `apiKey:write`, including ones added later.
        permissions:
          type: array
          items:
            $ref: '#/components/schemas/ApiKeyPermission'
          description: What the key holds, each write with the reads it needs.
        expiresAt:
          type:
            - string
            - 'null'
          format: date-time
          description: When the key stops working. `null` if it never expires.
        lastUsedAt:
          type:
            - string
            - 'null'
          format: date-time
          description: The last request made with the key, to the minute.
        createdAt:
          type: string
          format: date-time
        replacedBy:
          type:
            - string
            - 'null'
          format: uuid
          description: >-
            Set once the key was rotated: the id of the key that replaced it.
            This one works until `expiresAt`.
      required:
        - id
        - name
        - start
        - lastFour
        - status
        - fullAccess
        - permissions
        - expiresAt
        - lastUsedAt
        - createdAt
        - replacedBy
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key

````

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