# Create Service Key

> POST /api/v1/user/service-keys — request parameters and responses from the Menace Voice API schema.

`POST /api/v1/user/service-keys`

{/* Generated by scripts/sync_docs_api.mjs. Edit the API schema source to change the contract. */}

See [authentication](/api-reference/authentication) for workspace API access. Public embed and artifact endpoints use their documented session or access tokens.

## API contract for documentation tools

Generated from the OpenAPI schema. Do not infer a different parameter type from an example. Authentication headers are alternatives as explained in the authentication guide.

### Parameters

| Name | Location | Type | Required | Description and constraints |
| --- | --- | --- | --- | --- |
| authorization | header | string or null | no |  |
| X-API-Key | header | string or null | no |  |

### Request body: application/json

Required body. Schema: CreateServiceKeyRequest (object).

| Field | Type | Required | Description and constraints |
| --- | --- | --- | --- |
| name | string | yes |  |
| expires_in_days | integer or null | no | default: 90 |

### Response 200

Successful Response

application/json: CreateServiceKeyResponse (object).

| Field | Type | Required | Description and constraints |
| --- | --- | --- | --- |
| id | integer | yes |  |
| name | string | yes |  |
| service_key | string | yes |  |
| key_prefix | string | yes |  |
| expires_at | string or null | no |  |

### Response 404

Not found

### Response 422

Validation Error

application/json: HTTPValidationError (object).

| Field | Type | Required | Description and constraints |
| --- | --- | --- | --- |
| detail | array of ValidationError (object) | no |  |

## OpenAPI

````yaml api-reference/openapi.json post /api/v1/user/service-keys
openapi: 3.1.0
info:
  title: Menace Voice API
  description: API for Menace Voice agents
  version: 1.0.0
servers:
  - url: https://voice.menaceui.com
    description: Production
  - url: http://localhost:8000
    description: Local development
paths:
  /api/v1/user/service-keys:
    post:
      tags:
        - main
      summary: Create Service Key
      description: Create a new service key for the user's organization.
      operationId: create_service_key_api_v1_user_service_keys_post
      parameters:
        - name: authorization
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: "null"
            title: Authorization
        - name: X-API-Key
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: "null"
            title: X-Api-Key
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateServiceKeyRequest"
      responses:
        "200":
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CreateServiceKeyResponse"
        "404":
          description: Not found
        "422":
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/HTTPValidationError"
components:
  schemas:
    CreateServiceKeyRequest:
      properties:
        name:
          type: string
          title: Name
        expires_in_days:
          anyOf:
            - type: integer
            - type: "null"
          title: Expires In Days
          default: 90
      type: object
      required:
        - name
      title: CreateServiceKeyRequest
    CreateServiceKeyResponse:
      properties:
        id:
          type: integer
          title: Id
        name:
          type: string
          title: Name
        service_key:
          type: string
          title: Service Key
        key_prefix:
          type: string
          title: Key Prefix
        expires_at:
          anyOf:
            - type: string
              format: date-time
            - type: "null"
          title: Expires At
      type: object
      required:
        - id
        - name
        - service_key
        - key_prefix
      title: CreateServiceKeyResponse
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: "#/components/schemas/ValidationError"
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
````
