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

# Mint a child key

> Mint a scoped ScripX child API key for a sub-account or app: scopes are always a subset of the parent key, and the raw key is shown exactly once.

Self-serve sub-accounts: mint a child key with a label and a subset of your scopes. Returns `201`; the raw `api_key` appears **once**, in this response only.

A child key can never out-rank its parent: request a scope the parent lacks and the mint is refused. Omit `scopes` to inherit all of the parent's.

### Request example

```bash theme={"dark"}
curl -X POST "https://api.scripxhq.com/v1/keys" \
  -H "X-ScripX-Key: <YOUR_API_KEY>" \
  -H "Content-Type: application/json" \
  -d '{"label": "pricing-service", "scopes": ["quote", "market:read"]}'
```

### Response example

```json theme={"dark"}
{
  "created": true,
  "key": {
    "key_id": "key_01J01…",
    "label": "pricing-service",
    "scopes": ["quote", "market:read"],
    "api_key": "scripx_live_child_9c4…"
  }
}
```

Hand the raw key to the sub-account over a secure channel; you cannot retrieve it again.

### Errors

* `422 unprocessable`, missing `label` or scopes not a subset of yours.

**Terms used here:** [API key](/annexure/terminology#api-key), [child key](/annexure/terminology#child-key), [scope](/annexure/terminology#scope). Full list in the [terminology annexure](/annexure/terminology).

### Next steps

* [List keys](/api-reference/keys/list), [revoke](/api-reference/keys/revoke) when a sub-account winds down.


## OpenAPI

````yaml POST /v1/keys
openapi: 3.1.0
info:
  title: ScripX Partner API
  version: 1.2.0
  description: >-
    Automate duty-credit-scrip trading: quote, order, positions, market,
    webhooks. Auth: `X-ScripX-Key: scripx_live_…`. Money = integer paise; price
    = bps of face.
  contact:
    name: ScripX API Support
    email: amin@eximfiles.io
    url: https://scripxhq.com
servers:
  - url: https://api.scripxhq.com
    description: >-
      Production and sandbox share one host; a scripx_test_ key selects the
      sandbox.
security:
  - ApiKeyAuth: []
tags:
  - name: Firms
    description: >-
      client-firm lifecycle: register, verify, authorize, credits, update,
      offboard
  - name: Trading
    description: quote, orders, positions, market
  - name: Group
    description: intra-group netting + positions (enterprise/broker)
  - name: Cross
    description: 'broker cross-desk: block deals + intra-group transfers'
  - name: Webhooks
    description: event subscriptions + delivery
  - name: Account
    description: usage + metering
  - name: Keys
    description: self-serve scoped child keys (sub-accounts)
paths:
  /v1/keys:
    post:
      tags:
        - Keys
      summary: Mint a scoped child key (sub-account); scopes ⊆ this key's
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ChildKeyRequest'
      responses:
        '201':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChildKeyCreated'
        '401':
          description: Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - ApiKeyAuth: []
components:
  schemas:
    ChildKeyRequest:
      type: object
      required:
        - label
      properties:
        label:
          type: string
          description: human label for the sub-account
        scopes:
          type: array
          items:
            type: string
          description: subset of the parent key's scopes; omit to inherit all
    ChildKeyCreated:
      type: object
      properties:
        created:
          type: boolean
        key:
          type: object
          description: masked record + api_key (shown ONCE)
    Error:
      type: object
      properties:
        error:
          type: string
        code:
          type: string
          description: stable machine code
          enum:
            - bad_request
            - unauthorized
            - forbidden
            - not_found
            - conflict
            - unprocessable
            - rate_limited
            - internal
        message:
          type: string
        detail:
          type: object
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-ScripX-Key
      description: >-
        Your API key, e.g. `scripx_live_…`. Bound to one firm; tenant isolation
        is enforced.

````