{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/trajectory/json-schema/trajectory-create-api-key-response-schema.json",
  "title": "CreateApiKeyResponse",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/trajectory-api-keys-api-openapi.yml#/components/schemas/CreateApiKeyResponse",
  "properties": {
    "api_key": {
      "$ref": "#/$defs/ApiKey",
      "description": "Metadata for the newly created key."
    },
    "secret": {
      "type": "string",
      "title": "Secret",
      "description": "The plaintext API key. Returned only once at creation and never again — the caller must surface it to the user immediately."
    }
  },
  "type": "object",
  "required": [
    "api_key",
    "secret"
  ],
  "$defs": {
    "ApiKey": {
      "properties": {
        "key_hash": {
          "type": "string",
          "title": "Key Hash",
          "description": "Opaque identifier for the key (SHA-256 of the secret). Used to reference the key when revoking it; the secret itself is never returned after creation."
        },
        "key_prefix": {
          "type": "string",
          "title": "Key Prefix",
          "description": "Non-secret prefix shown to help identify the key."
        },
        "name": {
          "type": "string",
          "title": "Name",
          "description": "Human-readable label for the key."
        },
        "created_at": {
          "anyOf": [
            {
              "type": "string",
              "format": "date-time"
            },
            {
              "type": "null"
            }
          ],
          "title": "Created At",
          "description": "UTC timestamp the key was created."
        },
        "last_used_at": {
          "anyOf": [
            {
              "type": "string",
              "format": "date-time"
            },
            {
              "type": "null"
            }
          ],
          "title": "Last Used At",
          "description": "UTC timestamp the key was last used to authenticate, if ever."
        }
      },
      "type": "object",
      "required": [
        "key_hash",
        "key_prefix",
        "name"
      ],
      "title": "ApiKey"
    }
  }
}