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

# Create an API key

> Creates an API key for the workspace and returns the full key. This is the only time the key is shown, so store it right away. Send a unique `label`, and optionally `scopes` and `expiresAt`. Without `scopes` the new key gets the same scopes as the key that created it. The new key can never have more scopes or a later expiry than your own key.



## OpenAPI

````yaml https://monid.ai/openapi.json post /v1/api-keys
openapi: 3.1.0
info:
  title: Monid API
  version: 0.1.0
  description: >-
    Agentic payment platform for data. Agents use it to discover and buy data on
    demand. Authenticated routes take a Monid API key as a Bearer token. Errors
    return `{ code, message }`. List endpoints use cursor pagination.
servers:
  - url: https://api.monid.ai
    description: Production
security: []
paths:
  /v1/api-keys:
    post:
      tags:
        - API Keys
      summary: Create an API key
      description: >-
        Creates an API key for the workspace and returns the full key. This is
        the only time the key is shown, so store it right away. Send a unique
        `label`, and optionally `scopes` and `expiresAt`. Without `scopes` the
        new key gets the same scopes as the key that created it. The new key can
        never have more scopes or a later expiry than your own key.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateApiKeyRequest'
      responses:
        '201':
          description: API key created. The full key is in this response only.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiKeyCreated'
        '400':
          description: >-
            Bad request. The input failed validation, and `message` says which
            field.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Unauthorized. The API key is missing, invalid, expired or revoked.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: >-
            Forbidden. The API key lacks the scope this operation needs, or has
            no workspace.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: >-
            Rate limited. Wait the number of seconds in the `Retry-After`
            header, then retry. The `RateLimit-Limit`, `RateLimit-Remaining` and
            `RateLimit-Reset` headers describe the limit that applied.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '500':
          description: Internal server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - Bearer:
            - api_keys:create
components:
  schemas:
    CreateApiKeyRequest:
      type: object
      properties:
        label:
          type: string
          minLength: 1
          description: >-
            Human-readable label for the key. Unique among non-revoked keys in
            the workspace.
          example: ci-runner
        scopes:
          type: array
          items:
            type: string
            enum:
              - '*'
              - runs:*
              - resources:*
              - wallet:*
              - topups:*
              - controls:*
              - api_keys:*
              - runs:create
              - runs:get
              - runs:list
              - runs:update
              - resources:read
              - resources:create
              - resources:update
              - resources:delete
              - wallet:read
              - wallet:update
              - topups:create
              - controls:read
              - controls:create
              - controls:update
              - controls:delete
              - api_keys:read
              - api_keys:create
              - api_keys:update
              - api_keys:revoke
          minItems: 1
          description: >-
            Scopes for the new key. They must be a subset of your own key's
            scopes. Omit to copy your key's scopes.
          example:
            - runs:*
            - resources:*
            - wallet:read
            - topups:*
            - controls:read
            - api_keys:*
        expiresAt:
          type: string
          format: date-time
          description: >-
            When the key stops working, in ISO 8601. It cannot be later than
            your own key's expiry. Omit to use your key's expiry, or no expiry
            if your key has none. It cannot be changed later.
          example: '2027-01-01T00:00:00Z'
      required:
        - label
    ApiKeyCreated:
      type: object
      properties:
        apiKey:
          type: string
          description: >-
            The full API key. It is shown only once, so store it now. It cannot
            be retrieved again.
          example: monid_live_a1b2c3d4e5f6g7h8i9j0k1l2
        label:
          type: string
          example: ci-runner
        keyPrefix:
          type: string
          description: >-
            The start of the key, `monid_live_` in production. The full key is
            in `apiKey`.
          example: monid_live_
        workspaceId:
          type: string
          description: The workspace the key belongs to.
        owner:
          type: string
          description: The user the key belongs to.
        createdBy:
          type: string
          description: Who created the key.
          example: USER#user_2abc
        scopes:
          type: array
          items:
            type: string
            enum:
              - '*'
              - runs:*
              - resources:*
              - wallet:*
              - topups:*
              - controls:*
              - api_keys:*
              - runs:create
              - runs:get
              - runs:list
              - runs:update
              - resources:read
              - resources:create
              - resources:update
              - resources:delete
              - wallet:read
              - wallet:update
              - topups:create
              - controls:read
              - controls:create
              - controls:update
              - controls:delete
              - api_keys:read
              - api_keys:create
              - api_keys:update
              - api_keys:revoke
          minItems: 1
          description: >-
            The scopes the key holds, fixed at creation. See `GET
            /v1/api-keys/scopes` for every scope.
          example:
            - runs:*
            - resources:*
            - wallet:read
            - topups:*
            - controls:read
            - api_keys:*
        status:
          type: string
          enum:
            - ACTIVE
            - EXPIRED
            - REVOKED
          description: '`ACTIVE`, `EXPIRED` or `REVOKED`. Only active keys work.'
        origin:
          type: string
          enum:
            - DASHBOARD
            - API
            - AEP
            - SYSTEM
          description: How the key was created, such as `DASHBOARD` or `API`.
        expiresAt:
          type: string
          format: date-time
          description: >-
            When the key stops working, in ISO 8601. Absent when the key never
            expires.
        createdAt:
          type: string
          format: date-time
          description: Creation time (ISO 8601).
      required:
        - apiKey
        - label
        - keyPrefix
        - workspaceId
        - owner
        - createdBy
        - scopes
        - status
        - origin
        - createdAt
    Error:
      type: object
      properties:
        code:
          type: integer
          description: HTTP status code, duplicated in the body.
          example: 400
        message:
          type: string
          description: Human-readable error description.
          example: Bad Request
        hints:
          type: object
          additionalProperties:
            anyOf:
              - type: string
              - type: object
                properties:
                  kind:
                    type: string
                    enum:
                      - command
                      - discover
                      - inspect
                      - run
                      - getRun
                      - stop
                      - releaseResource
                      - topup
                  command:
                    type: string
                  query:
                    type: string
                  provider:
                    type: string
                  endpoint:
                    type: string
                  runId:
                    type: string
                  resourceId:
                    type: string
                  stripe:
                    type: string
                  dashboard:
                    type: string
                  docs:
                    type: string
                  comment:
                    type: string
                required:
                  - kind
          description: >-
            Optional next actions, rendered for the calling client like
            run-response hints (e.g. the paid TinyFish version on a free-quota
            429 — spending permission required).
        errorCode:
          type: string
          enum:
            - RATE_LIMITED
            - X402_WORKSPACE_RESOURCES
            - X402_WORKSPACE_ONLY
            - X402_ACCRUING_COST
            - X402_EXCEEDS_SETTLEMENT_WINDOW
            - X402_VALIDITY_WINDOW_TOO_SHORT
            - X402_UNBOUNDED_PRICE
            - X402_PROMOTION
            - INSUFFICIENT_SCOPE
            - WALLET_INSUFFICIENT_FUNDS
            - IDENTITY_PROVIDER_UNKNOWN
            - IDENTITY_LINK_REQUIRES_SESSION
            - IDENTITY_LINK_STATE_INVALID
            - IDENTITY_VERIFICATION_FAILED
            - IDENTITY_PROVIDER_UNAVAILABLE
            - IDENTITY_ALREADY_LINKED
            - IDENTITY_USER_ALREADY_LINKED
            - IDENTITY_LINK_RATE_LIMITED
            - IDENTITY_REQUIRED
            - PROMO_IDENTITY_REDEEMED
            - PROMO_REDEEM_REQUIRES_SESSION
            - PROMO_CODE_REDEEMED_BY_WORKSPACE
            - PROMO_CODE_REDEEMED_BY_USER
          description: >-
            OPTIONAL machine-readable discriminant from the documented
            `ApiErrorCode` registry. Absent on legacy errors; clients MUST treat
            unknown values as absent.
      required:
        - code
        - message
  securitySchemes:
    Bearer:
      type: http
      scheme: bearer
      description: Monid API key
      x-aep-authentication-method: api-key

````

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