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

# Mint a key

> Mint an API key. `plaintextKey` is returned **once**; store it now. Pass `scopes`: a key with none works only on `GET /v1/me`. A key-authed caller cannot grant a scope it doesn't hold (`insufficient_scope`), and a publishable key may hold only `objects:read` and `usage:write` (`scope_not_grantable`). A secret key needs a plan with API access (`api_access_not_on_plan`). **Requires scope:** `applications:manage`. Also accepts a signed-in session instead of a key (the bootstrap path the CLI and dashboard use before a key exists). A session caller must be a workspace admin.



## OpenAPI

````yaml /openapi-v1.json post /v1/applications/{id}/keys
openapi: 3.1.0
info:
  title: Custral API
  version: v1
  description: >-
    The curated, versioned, API-key-authenticated public REST surface (`/v1`).
    Every endpoint here is what the official SDKs (`@custral/sdk`) and the MCP
    server are built on. Authenticate with a secret API key (`sk_…`) created in
    **Settings → Developers → Applications**.


    Every `/v1` response is sent with **HTTP 200**, success and failure alike. A
    success carries `data`; a failure carries `error` with a machine-readable
    `code` (see the `Error` schema), so branch on `error`, never on the status.
    `POST /v1/mcp` is the one exception: it answers auth failures with real 401
    / 403 / 429 statuses, as MCP clients expect.
  contact:
    name: Custral Support
    email: hello@custral.com
    url: https://custral.com
  license:
    name: Proprietary
    url: https://custral.com
servers:
  - url: https://api.custral.com
    description: Production
security:
  - ApiKey: []
tags:
  - name: Identity
    description: Introspect the calling API key.
  - name: Records
    description: Create, list, retrieve, and update records on any object.
  - name: Objects
    description: Read the object (table) schema of your workspace.
  - name: Conversations
    description: View, manage, and ingest conversations and their messages.
  - name: MCP
    description: Custral's MCP server, and the tool surface a key sees on it.
  - name: Documents
    description: Read record notes / page documents as markdown.
  - name: Connectors
    description: The MCP servers Stella can use tools from.
  - name: Property agents
    description: AI auto-fill agents on properties.
  - name: Usage modules
    description: Metered-product setups, their usage events, and per-record usage.
  - name: Applications & keys
    description: Developer applications and the API keys they hold.
  - name: Widget identity
    description: Vouch for who a chat widget visitor is.
  - name: Embeds & real-time
    description: Read the rows behind your own embed block, with an embed token.
  - name: Lists
    description: Read lists and change who is on them.
  - name: Customer journeys
    description: The workspace's customer journey, and where each customer is in it.
  - name: Quotes
    description: Quotes, contracts and contract templates.
  - name: Billing
    description: >-
      Customer billing, invoices, subscriptions, revenue metrics, the billing
      page, Stripe customer links, billing setup, products and plans.
paths:
  /v1/applications/{id}/keys:
    post:
      tags:
        - Applications & keys
      summary: Mint a key
      description: >-
        Mint an API key. `plaintextKey` is returned **once**; store it now. Pass
        `scopes`: a key with none works only on `GET /v1/me`. A key-authed
        caller cannot grant a scope it doesn't hold (`insufficient_scope`), and
        a publishable key may hold only `objects:read` and `usage:write`
        (`scope_not_grantable`). A secret key needs a plan with API access
        (`api_access_not_on_plan`). **Requires scope:** `applications:manage`.
        Also accepts a signed-in session instead of a key (the bootstrap path
        the CLI and dashboard use before a key exists). A session caller must be
        a workspace admin.
      operationId: createApplicationKey
      parameters:
        - name: id
          in: path
          required: true
          description: The application id.
          schema:
            type: string
          example: app_3Ab9xK2mQ7
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateApplicationKeyBody'
      responses:
        '200':
          description: The new key and its secret.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/CreatedApplicationKey'
                  reqId:
                    $ref: '#/components/schemas/RequestId'
components:
  schemas:
    CreateApplicationKeyBody:
      type: object
      properties:
        type:
          type: string
          enum:
            - publishable
            - secret
        name:
          type: string
          example: Production server
        scopes:
          type: array
          items:
            $ref: '#/components/schemas/ApiKeyScope'
          description: >-
            What the key may do. A key with no scopes authenticates but is
            refused everywhere except `GET /v1/me`, so always pass them.
        environment:
          type: string
          enum:
            - live
            - test
          description: Defaults to `live`.
        expiresInDays:
          type:
            - integer
            - 'null'
          description: >-
            Expire the key after this many days. Omit, or send null, for a key
            that never expires.
          minimum: 1
      required:
        - type
    CreatedApplicationKey:
      type: object
      properties:
        key:
          $ref: '#/components/schemas/ApplicationKey'
        plaintextKey:
          type: string
          description: The secret. Returned once, at creation; only its hash is stored.
          example: sk_live_4f8a…
      required:
        - key
        - plaintextKey
    RequestId:
      type: string
      description: >-
        A per-request id (`req_…`). Quote it to support when reporting a
        problem.
      example: req_2a1f9c8e7b6d5
    ApiKeyScope:
      type: string
      description: >-
        A permission a key can hold. A publishable (`pk_…`) key may hold only
        `objects:read` and `usage:write`.
      enum:
        - records:read
        - records:write
        - objects:read
        - documents:read
        - documents:write
        - conversations:read
        - conversations:write
        - property_agents:read
        - property_agents:write
        - tasks:read
        - usage:read
        - usage:write
        - quotes:write
        - billing:read
        - billing:admin
        - billing:portal
        - applications:manage
        - webhooks:manage
        - connectors:read
        - connectors:manage
        - mcp:read
        - mcp:write
        - widget:identify
        - widget:manage
    ApplicationKey:
      type: object
      description: An API key's metadata. The secret itself is never returned here.
      properties:
        id:
          type: string
          description: The key's id (not the secret).
          example: key_5Bc0xJ1kP4
        applicationId:
          type:
            - string
            - 'null'
        name:
          type:
            - string
            - 'null'
          example: Production server
        type:
          type:
            - string
            - 'null'
          enum:
            - publishable
            - secret
            - null
          description: >-
            `secret` (`sk_…`, server only) or `publishable` (`pk_…`,
            browser-safe).
        keyPreview:
          type:
            - string
            - 'null'
          description: The first and last characters, for telling keys apart.
          example: sk_live_…a1b2
        scopes:
          type: array
          items:
            $ref: '#/components/schemas/ApiKeyScope'
        environment:
          type:
            - string
            - 'null'
          enum:
            - live
            - test
            - null
        status:
          type:
            - string
            - 'null'
          enum:
            - active
            - inactive
            - null
          description: '`inactive` once revoked.'
        expiresAt:
          type:
            - string
            - 'null'
          format: date-time
        lastUsedAt:
          type:
            - string
            - 'null'
          format: date-time
        createdAt:
          type:
            - string
            - 'null'
          format: date-time
      required:
        - id
        - scopes
  securitySchemes:
    ApiKey:
      type: http
      scheme: bearer
      bearerFormat: sk_...
      description: >-
        A Custral API key, created in Settings → Developers → Applications, sent
        as `Authorization: Bearer sk_…`. The `X-Api-Key` header is also accepted
        and takes precedence. Use a **secret** key (`sk_…`) from your server; a
        publishable key (`pk_…`) may hold only `objects:read` and `usage:write`.
        Never expose a secret key in a browser.

````

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