{
  "openapi": "3.1.1",
  "info": {
    "title": "Agentpost Platform API",
    "version": "v1",
    "description": "Every operation of the Agentpost Platform API, generated with its [API reference](https://agentpost.tools/docs/platform/reference) from the code that serves it, so the two agree.\n\n- **Base URL:** every path starts with `https://api.agentpost.tools/v1`.\n- **Credentials:** send one as `Authorization: Bearer <token>`. Each operation lists the ones it takes, and [Platform credentials](https://agentpost.tools/docs/platform/concepts/credentials) explains each.\n- **Idempotency:** No operation in this reference takes `Idempotency-Key`. Before you retry a write that may have succeeded, read the resource to see whether it did. Writes under `/v1/platform` are IdentityHound’s operations and follow [its key rules](https://agentpost.tools/docs/identityhound/reference#conventions).\n- **Lists:** Every list takes `limit`, 1 to 200. [Read a workspace's events](https://agentpost.tools/docs/platform/reference/workspaces#read-a-workspaces-events) is a feed. [Lists](https://agentpost.tools/docs/platform/api-basics#lists) has the rule.\n- **IDs:** Each ID starts with its kind's prefix, such as `prn_…`. [Platform's ID prefixes](https://agentpost.tools/docs/platform/reference#ids) lists them.\n- **Errors:** On the operations in this reference, an error's `docs` link goes to its code's entry on [Agentpost errors](https://agentpost.tools/docs/errors). [API basics](https://agentpost.tools/docs/platform/api-basics#errors) explains which errors page `/v1/platform` links to. Any operation can answer with [`invalid_request`](https://agentpost.tools/docs/errors#invalid_request), [`unauthenticated`](https://agentpost.tools/docs/errors#unauthenticated), [`secret_key_invalid`](https://agentpost.tools/docs/errors#secret_key_invalid), [`origin_not_allowed`](https://agentpost.tools/docs/errors#origin_not_allowed), [`not_ready`](https://agentpost.tools/docs/errors#not_ready), or [`internal_error`](https://agentpost.tools/docs/errors#internal_error); each operation lists the other codes it can answer with. [Errors](https://agentpost.tools/docs/platform/api-basics#errors) describes the body.\n- **Rules every API shares:** [API basics](https://agentpost.tools/docs/platform/api-basics).",
    "termsOfService": "https://agentpost.tools/terms"
  },
  "servers": [
    {
      "url": "https://api.agentpost.tools"
    }
  ],
  "externalDocs": {
    "description": "The Agentpost Platform API reference",
    "url": "https://agentpost.tools/docs/platform/reference"
  },
  "tags": [
    {
      "name": "Signup and workspaces",
      "description": "A principal, an agent or a human, starts with one request: signup makes it a workspace it owns and its first API key. A principal that signed in with an emailed code creates a workspace through IdentityHound’s routes instead. A workspace holds its projects, keys, and members, each member with a role.",
      "externalDocs": {
        "url": "https://agentpost.tools/docs/platform/reference/workspaces"
      }
    },
    {
      "name": "Projects",
      "description": "A project is one product. It belongs to a workspace, adopts the services it uses, and has a `dev` and a `prd` environment with separate data.",
      "externalDocs": {
        "url": "https://agentpost.tools/docs/platform/reference/projects"
      }
    },
    {
      "name": "Keys",
      "description": "A project's keys. A secret key, `sk_test_…` for `dev` or `sk_live_…` for `prd`, is for your server: it is shown once and stored as a hash. A publishable key, `pk_test_…` or `pk_live_…`, is for a browser or a native app: it is public, works only from the origins it lists or, when it allows native apps, with no origin, and reaches only a service's sign-in operations. The workspace's owners get an email whenever a key is issued or rotated, or its origins or native allowance change. A workspace key, `wk_test_…` or `wk_live_…`, belongs to a workspace rather than a project: it reads every project of the workspace in its environment, within the permissions it was issued with, and is shown once, stored as a hash, and rotated like a secret key.",
      "externalDocs": {
        "url": "https://agentpost.tools/docs/platform/reference/keys"
      }
    },
    {
      "name": "Sending domain",
      "description": "A project's email, sign-in codes included, comes from a domain it verified; until one verifies, it sends none, except to a `dev` environment's test inbox. Add the domain, then add the DNS records the answer lists. Agentpost checks every 5 minutes for the first hour, then hourly, for up to 72 hours, and emails the workspace's owners when the domain verifies or fails. A domain belongs to the first workspace that adds it; if it fails to verify, another workspace may add it.",
      "externalDocs": {
        "url": "https://agentpost.tools/docs/platform/reference/sending-domain"
      }
    },
    {
      "name": "Test inbox",
      "description": "In a `dev` environment, a project's email to an address at `.test`, such as a sign-in code, waits here for an hour instead of being sent, so tests and agents sign in with made-up addresses and no mailbox. Agentpost's own email, such as a workspace invitation, is always sent to its address.",
      "externalDocs": {
        "url": "https://agentpost.tools/docs/platform/reference/test-inbox"
      }
    },
    {
      "name": "User tokens",
      "description": "A user token, `ut_test_…` or `ut_live_…`, is what a browser sends for whoever is signed in to your project, however they signed in. It lasts 15 minutes by default and an hour at most. Services treat it like that principal's session.",
      "externalDocs": {
        "url": "https://agentpost.tools/docs/platform/reference/user-tokens"
      }
    }
  ],
  "paths": {
    "/v1/signup/start": {
      "post": {
        "operationId": "signup.start",
        "summary": "Sign up",
        "description": "Creates a principal, a workspace it owns, and the principal's first API key, which never expires. The principal may say what it is. The workspace starts with a limit of 100 projects. One address may start 10 signups an hour.\n\n- **Who may call:** Anyone, with no credential.",
        "tags": ["Signup and workspaces"],
        "externalDocs": {
          "description": "Sign up, in the API reference",
          "url": "https://agentpost.tools/docs/platform/reference/workspaces#sign-up"
        },
        "security": [],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "kind": {
                    "description": "What the principal is. Leave it out to say nothing",
                    "type": "string",
                    "enum": ["agent", "human", "service"]
                  },
                  "displayName": {
                    "description": "A name to show for the principal",
                    "type": "string",
                    "maxLength": 120
                  },
                  "workspaceName": {
                    "description": "Default `My workspace`",
                    "type": "string",
                    "maxLength": 120
                  }
                },
                "additionalProperties": false
              },
              "example": {
                "kind": "agent",
                "displayName": "Helper",
                "workspaceName": "My workspace"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "principal": {
                      "$ref": "#/components/schemas/Principal"
                    },
                    "workspace": {
                      "$ref": "#/components/schemas/Workspace"
                    },
                    "apiKey": {
                      "type": "string",
                      "description": "The principal's API key, `agp_ak_apoa_…`. Shown once"
                    }
                  },
                  "required": ["principal", "workspace", "apiKey"],
                  "additionalProperties": false
                },
                "example": {
                  "principal": {
                    "id": "prn_01JDSJ41R3JK54F6RKD4Y3J1GF",
                    "kind": "agent",
                    "status": "active",
                    "displayName": "Helper",
                    "projectRoles": [],
                    "lastActiveAt": "2026-11-12T15:00:00.000Z",
                    "createdAt": "2026-11-12T15:00:00.000Z",
                    "updatedAt": "2026-11-12T15:00:00.000Z",
                    "metadata": {}
                  },
                  "workspace": {
                    "id": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62",
                    "name": "My workspace",
                    "status": "active",
                    "projects": {
                      "used": 0,
                      "max": 100
                    },
                    "createdAt": "2026-11-12T15:00:00.000Z"
                  },
                  "apiKey": "agp_ak_apoa_…"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/errors#unauthenticated) or [`secret_key_invalid`](https://agentpost.tools/docs/errors#secret_key_invalid).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated", "secret_key_invalid"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/errors#forbidden) or [`origin_not_allowed`](https://agentpost.tools/docs/errors#origin_not_allowed).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden", "origin_not_allowed"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "429": {
            "description": "Too Many Requests, with `error.code` [`throttled`](https://agentpost.tools/docs/errors#throttled).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["throttled"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "503": {
            "description": "Service Unavailable, with `error.code` [`not_ready`](https://agentpost.tools/docs/errors#not_ready).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_ready"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/v1/workspaces/{workspaceId}": {
      "get": {
        "operationId": "workspaces.get",
        "summary": "Get a workspace",
        "description": "A workspace, with how many projects it holds and may hold.\n\n- **Who may call:** A member of the workspace, with its API key; a member of the workspace, with its session; or a delegate, with its delegated token.\n- **Access:** The caller holds `identity.workspace:view` in the workspace. A workspace the caller has no part in is not found.",
        "tags": ["Signup and workspaces"],
        "externalDocs": {
          "description": "Get a workspace, in the API reference",
          "url": "https://agentpost.tools/docs/platform/reference/workspaces#get-a-workspace"
        },
        "security": [
          {
            "apiKey": []
          },
          {
            "platformSession": []
          },
          {
            "delegatedToken": []
          }
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "in": "path",
            "required": true,
            "description": "A workspace ID, `wsp_…`. It is `workspace.id` in the answer to [Sign up](https://agentpost.tools/docs/platform/reference/workspaces#sign-up).",
            "schema": {
              "type": "string"
            },
            "example": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "workspace": {
                      "$ref": "#/components/schemas/Workspace"
                    }
                  },
                  "required": ["workspace"],
                  "additionalProperties": false
                },
                "example": {
                  "workspace": {
                    "id": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62",
                    "name": "My workspace",
                    "status": "active",
                    "projects": {
                      "used": 1,
                      "max": 100
                    },
                    "createdAt": "2026-11-12T15:00:00.000Z"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/errors#unauthenticated) or [`secret_key_invalid`](https://agentpost.tools/docs/errors#secret_key_invalid).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated", "secret_key_invalid"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/errors#forbidden) or [`origin_not_allowed`](https://agentpost.tools/docs/errors#origin_not_allowed).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden", "origin_not_allowed"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "503": {
            "description": "Service Unavailable, with `error.code` [`not_ready`](https://agentpost.tools/docs/errors#not_ready).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_ready"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/v1/workspaces/{workspaceId}/events": {
      "get": {
        "operationId": "workspaces.events",
        "summary": "Read a workspace's events",
        "description": "What changed in the workspace, oldest first: its projects, keys, members, invitations, delegations, and sending domains, and who changed each. Pass the `next` of one read as `after` in the next.\n\n- **Who may call:** A member of the workspace, with its API key; a member of the workspace, with its session; or a delegate, with its delegated token.\n- **Access:** The caller holds `apoa.event:view` in the workspace. A workspace the caller has no part in is not found. A workspace key is refused.\n- **Pages:** `limit`, 1 to 200. A feed: every answer has `next`, to send as `after`. [Lists](https://agentpost.tools/docs/platform/api-basics#lists) has the rule.",
        "tags": ["Signup and workspaces"],
        "externalDocs": {
          "description": "Read a workspace's events, in the API reference",
          "url": "https://agentpost.tools/docs/platform/reference/workspaces#read-a-workspaces-events"
        },
        "security": [
          {
            "apiKey": []
          },
          {
            "platformSession": []
          },
          {
            "delegatedToken": []
          }
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "in": "path",
            "required": true,
            "description": "A workspace ID, `wsp_…`. It is `workspace.id` in the answer to [Sign up](https://agentpost.tools/docs/platform/reference/workspaces#sign-up).",
            "schema": {
              "type": "string"
            },
            "example": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62"
          },
          {
            "name": "after",
            "in": "query",
            "required": false,
            "description": "The last `sequence` you read. Default `0`, from the first event; at least 0.",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            },
            "example": 48210
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "At most this many events. Default `50`; 1–200.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200
            },
            "example": 50
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "events": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/WorkspaceEvent"
                      }
                    },
                    "next": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 9007199254740991,
                      "description": "Pass as `after` to read on. The last `sequence` in `events`, or your `after` when nothing changed since"
                    }
                  },
                  "required": ["events", "next"],
                  "additionalProperties": false
                },
                "example": {
                  "events": [
                    {
                      "id": "access.updated:key:rotated:key_01JDZ6AJ7K56PD5A8JS97ZWT3G",
                      "sequence": 48211,
                      "type": "access.updated",
                      "time": "2026-11-13T09:30:00.000Z",
                      "summary": "A secret prd key was rotated for My app (My workspace)",
                      "actor": "principal:prn_01JDTQ8B2C3D4E5F6G7H8J9K0M",
                      "onBehalfOf": "principal:prn_01JDSJ41R3JK54F6RKD4Y3J1GF",
                      "data": {
                        "kind": "key",
                        "change": "rotated",
                        "workspaceId": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62",
                        "projectId": "prj_01JDKYC5RZKAFFK3K2ENNC1ZTK",
                        "keyId": "key_01JDZ6AJ7K56PD5A8JS97ZWT3G",
                        "keyType": "secret",
                        "environment": "prd",
                        "previousKeyId": "key_01JDZ11YP80FXYTCSE1CE31KM0"
                      }
                    }
                  ],
                  "next": 48211
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/errors#unauthenticated) or [`secret_key_invalid`](https://agentpost.tools/docs/errors#secret_key_invalid).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated", "secret_key_invalid"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/errors#forbidden) or [`origin_not_allowed`](https://agentpost.tools/docs/errors#origin_not_allowed).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden", "origin_not_allowed"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "503": {
            "description": "Service Unavailable, with `error.code` [`unavailable`](https://agentpost.tools/docs/errors#unavailable) or [`not_ready`](https://agentpost.tools/docs/errors#not_ready).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unavailable", "not_ready"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/v1/projects": {
      "get": {
        "operationId": "projects.list",
        "summary": "List projects",
        "description": "The projects the caller may view, oldest first.\n\n- **Who may call:** A member of the workspace, with its API key; a member of the workspace, with its session; or a delegate, with its delegated token.\n- **Access:** The caller holds `apoa.project:view` in the project's workspace.",
        "tags": ["Projects"],
        "externalDocs": {
          "description": "List projects, in the API reference",
          "url": "https://agentpost.tools/docs/platform/reference/projects#list-projects"
        },
        "security": [
          {
            "apiKey": []
          },
          {
            "platformSession": []
          },
          {
            "delegatedToken": []
          }
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "in": "query",
            "required": false,
            "description": "Only the projects in this workspace.",
            "schema": {
              "type": "string"
            },
            "example": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "projects": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Project"
                      }
                    }
                  },
                  "required": ["projects"],
                  "additionalProperties": false
                },
                "example": {
                  "projects": [
                    {
                      "id": "prj_01JDKYC5RZKAFFK3K2ENNC1ZTK",
                      "workspaceId": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62",
                      "name": "My app",
                      "services": ["identityhound"],
                      "status": "active",
                      "createdAt": "2026-11-13T09:30:00.000Z"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/errors#unauthenticated) or [`secret_key_invalid`](https://agentpost.tools/docs/errors#secret_key_invalid).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated", "secret_key_invalid"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/errors#forbidden) or [`origin_not_allowed`](https://agentpost.tools/docs/errors#origin_not_allowed).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden", "origin_not_allowed"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "503": {
            "description": "Service Unavailable, with `error.code` [`not_ready`](https://agentpost.tools/docs/errors#not_ready).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_ready"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "projects.create",
        "summary": "Create a project",
        "description": "Creates a project in a workspace. It counts against the workspace's project limit.\n\n- **Who may call:** A member of the workspace, with its API key; a member of the workspace, with its session; or a delegate, with its delegated token.\n- **Access:** The caller holds `apoa.project:create` in the project's workspace.",
        "tags": ["Projects"],
        "externalDocs": {
          "description": "Create a project, in the API reference",
          "url": "https://agentpost.tools/docs/platform/reference/projects#create-a-project"
        },
        "security": [
          {
            "apiKey": []
          },
          {
            "platformSession": []
          },
          {
            "delegatedToken": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "workspaceId": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 120
                  }
                },
                "required": ["workspaceId", "name"],
                "additionalProperties": false
              },
              "example": {
                "workspaceId": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62",
                "name": "My app"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "project": {
                      "$ref": "#/components/schemas/Project"
                    }
                  },
                  "required": ["project"],
                  "additionalProperties": false
                },
                "example": {
                  "project": {
                    "id": "prj_01JDKYC5RZKAFFK3K2ENNC1ZTK",
                    "workspaceId": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62",
                    "name": "My app",
                    "services": [],
                    "status": "active",
                    "createdAt": "2026-11-13T09:30:00.000Z"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/errors#unauthenticated) or [`secret_key_invalid`](https://agentpost.tools/docs/errors#secret_key_invalid).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated", "secret_key_invalid"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/errors#forbidden), [`quota_exceeded`](https://agentpost.tools/docs/errors#quota_exceeded), or [`origin_not_allowed`](https://agentpost.tools/docs/errors#origin_not_allowed).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": [
                                "forbidden",
                                "quota_exceeded",
                                "origin_not_allowed"
                              ]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "503": {
            "description": "Service Unavailable, with `error.code` [`not_ready`](https://agentpost.tools/docs/errors#not_ready).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_ready"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/v1/projects/{id}": {
      "get": {
        "operationId": "projects.get",
        "summary": "Get a project",
        "description": "One project.\n\n- **Who may call:** A member of the workspace, with its API key; a member of the workspace, with its session; or a delegate, with its delegated token.\n- **Access:** The caller holds `apoa.project:view` in the project's workspace.",
        "tags": ["Projects"],
        "externalDocs": {
          "description": "Get a project, in the API reference",
          "url": "https://agentpost.tools/docs/platform/reference/projects#get-a-project"
        },
        "security": [
          {
            "apiKey": []
          },
          {
            "platformSession": []
          },
          {
            "delegatedToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "A project ID, `prj_…`. The `id` of a [`Project`](https://agentpost.tools/docs/platform/reference/projects#the-project-object).",
            "schema": {
              "type": "string"
            },
            "example": "prj_01JDKYC5RZKAFFK3K2ENNC1ZTK"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "project": {
                      "$ref": "#/components/schemas/Project"
                    }
                  },
                  "required": ["project"],
                  "additionalProperties": false
                },
                "example": {
                  "project": {
                    "id": "prj_01JDKYC5RZKAFFK3K2ENNC1ZTK",
                    "workspaceId": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62",
                    "name": "My app",
                    "services": ["identityhound"],
                    "status": "active",
                    "createdAt": "2026-11-13T09:30:00.000Z"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/errors#unauthenticated) or [`secret_key_invalid`](https://agentpost.tools/docs/errors#secret_key_invalid).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated", "secret_key_invalid"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/errors#forbidden) or [`origin_not_allowed`](https://agentpost.tools/docs/errors#origin_not_allowed).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden", "origin_not_allowed"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "503": {
            "description": "Service Unavailable, with `error.code` [`not_ready`](https://agentpost.tools/docs/errors#not_ready).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_ready"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "projects.rename",
        "summary": "Rename a project",
        "description": "Renames a project.\n\n- **Who may call:** A member of the workspace, with its API key; a member of the workspace, with its session; or a delegate, with its delegated token.\n- **Access:** The caller holds `apoa.project:update` in the project's workspace.",
        "tags": ["Projects"],
        "externalDocs": {
          "description": "Rename a project, in the API reference",
          "url": "https://agentpost.tools/docs/platform/reference/projects#rename-a-project"
        },
        "security": [
          {
            "apiKey": []
          },
          {
            "platformSession": []
          },
          {
            "delegatedToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "A project ID, `prj_…`. The `id` of a [`Project`](https://agentpost.tools/docs/platform/reference/projects#the-project-object).",
            "schema": {
              "type": "string"
            },
            "example": "prj_01JDKYC5RZKAFFK3K2ENNC1ZTK"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 120
                  }
                },
                "required": ["name"],
                "additionalProperties": false
              },
              "example": {
                "name": "My game"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "project": {
                      "$ref": "#/components/schemas/Project"
                    }
                  },
                  "required": ["project"],
                  "additionalProperties": false
                },
                "example": {
                  "project": {
                    "id": "prj_01JDKYC5RZKAFFK3K2ENNC1ZTK",
                    "workspaceId": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62",
                    "name": "My game",
                    "services": ["identityhound"],
                    "status": "active",
                    "createdAt": "2026-11-13T09:30:00.000Z"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/errors#unauthenticated) or [`secret_key_invalid`](https://agentpost.tools/docs/errors#secret_key_invalid).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated", "secret_key_invalid"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/errors#forbidden) or [`origin_not_allowed`](https://agentpost.tools/docs/errors#origin_not_allowed).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden", "origin_not_allowed"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "503": {
            "description": "Service Unavailable, with `error.code` [`not_ready`](https://agentpost.tools/docs/errors#not_ready).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_ready"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "projects.delete",
        "summary": "Delete a project",
        "description": "Deletes a project: revokes its keys at once, revokes the tokens of its connections at their providers, such as Twitch, and removes its records from every service, in both environments. It can't be undone, so it needs the project's name as confirmation.\n\n- **Who may call:** A member of the workspace, with its API key; a member of the workspace, with its session; or a delegate, with its delegated token.\n- **Access:** The caller holds `apoa.project:delete` in the project's workspace. Only an owner holds it.",
        "tags": ["Projects"],
        "externalDocs": {
          "description": "Delete a project, in the API reference",
          "url": "https://agentpost.tools/docs/platform/reference/projects#delete-a-project"
        },
        "security": [
          {
            "apiKey": []
          },
          {
            "platformSession": []
          },
          {
            "delegatedToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "A project ID, `prj_…`. The `id` of a [`Project`](https://agentpost.tools/docs/platform/reference/projects#the-project-object).",
            "schema": {
              "type": "string"
            },
            "example": "prj_01JDKYC5RZKAFFK3K2ENNC1ZTK"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "confirm": {
                    "type": "string",
                    "description": "The project's name"
                  }
                },
                "required": ["confirm"],
                "additionalProperties": false
              },
              "example": {
                "confirm": "My app"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "project": {
                      "$ref": "#/components/schemas/Project"
                    },
                    "recordsRemoved": {
                      "type": "boolean",
                      "description": "False while some of its records are still being removed, such as while many tokens are revoked at their providers; the removal carries on, and an hourly sweep finishes anything left"
                    }
                  },
                  "required": ["project", "recordsRemoved"],
                  "additionalProperties": false
                },
                "example": {
                  "project": {
                    "id": "prj_01JDKYC5RZKAFFK3K2ENNC1ZTK",
                    "workspaceId": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62",
                    "name": "My app",
                    "services": ["identityhound"],
                    "status": "deleted",
                    "createdAt": "2026-11-13T09:30:00.000Z",
                    "deletedAt": "2026-11-13T09:30:00.000Z"
                  },
                  "recordsRemoved": true
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`confirmation_required`](https://agentpost.tools/docs/errors#confirmation_required) or [`invalid_request`](https://agentpost.tools/docs/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": [
                                "confirmation_required",
                                "invalid_request"
                              ]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/errors#unauthenticated) or [`secret_key_invalid`](https://agentpost.tools/docs/errors#secret_key_invalid).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated", "secret_key_invalid"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/errors#forbidden) or [`origin_not_allowed`](https://agentpost.tools/docs/errors#origin_not_allowed).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden", "origin_not_allowed"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "503": {
            "description": "Service Unavailable, with `error.code` [`not_ready`](https://agentpost.tools/docs/errors#not_ready).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_ready"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/v1/projects/{id}/services": {
      "post": {
        "operationId": "projects.adopt",
        "summary": "Adopt a service",
        "description": "Adopts a service, such as IdentityHound, which then answers at its path under the API root, such as `/v1/identity`, for this project's keys. Adopting one the project already has changes nothing.\n\n- **Who may call:** A member of the workspace, with its API key; a member of the workspace, with its session; or a delegate, with its delegated token.\n- **Access:** The caller holds `apoa.project:adopt` in the project's workspace.",
        "tags": ["Projects"],
        "externalDocs": {
          "description": "Adopt a service, in the API reference",
          "url": "https://agentpost.tools/docs/platform/reference/projects#adopt-a-service"
        },
        "security": [
          {
            "apiKey": []
          },
          {
            "platformSession": []
          },
          {
            "delegatedToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "A project ID, `prj_…`. The `id` of a [`Project`](https://agentpost.tools/docs/platform/reference/projects#the-project-object).",
            "schema": {
              "type": "string"
            },
            "example": "prj_01JDKYC5RZKAFFK3K2ENNC1ZTK"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "service": {
                    "type": "string",
                    "description": "Such as `identityhound`"
                  }
                },
                "required": ["service"],
                "additionalProperties": false
              },
              "example": {
                "service": "identityhound"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "project": {
                      "$ref": "#/components/schemas/Project"
                    },
                    "adopted": {
                      "type": "boolean",
                      "description": "False when the project had already adopted it"
                    }
                  },
                  "required": ["project", "adopted"],
                  "additionalProperties": false
                },
                "example": {
                  "project": {
                    "id": "prj_01JDKYC5RZKAFFK3K2ENNC1ZTK",
                    "workspaceId": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62",
                    "name": "My app",
                    "services": ["identityhound"],
                    "status": "active",
                    "createdAt": "2026-11-13T09:30:00.000Z"
                  },
                  "adopted": true
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/errors#unauthenticated) or [`secret_key_invalid`](https://agentpost.tools/docs/errors#secret_key_invalid).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated", "secret_key_invalid"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/errors#forbidden) or [`origin_not_allowed`](https://agentpost.tools/docs/errors#origin_not_allowed).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden", "origin_not_allowed"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "503": {
            "description": "Service Unavailable, with `error.code` [`not_ready`](https://agentpost.tools/docs/errors#not_ready).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_ready"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/v1/projects/{id}/keys": {
      "get": {
        "operationId": "keys.list",
        "summary": "List keys",
        "description": "Every key of the project, oldest first, revoked ones included. Never a secret key's secret.\n\n- **Who may call:** A member of the workspace, with its API key; a member of the workspace, with its session; or a delegate, with its delegated token.\n- **Access:** The caller holds `apoa.key:view` in the project's workspace.",
        "tags": ["Keys"],
        "externalDocs": {
          "description": "List keys, in the API reference",
          "url": "https://agentpost.tools/docs/platform/reference/keys#list-keys"
        },
        "security": [
          {
            "apiKey": []
          },
          {
            "platformSession": []
          },
          {
            "delegatedToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "A project ID, `prj_…`. The `id` of a [`Project`](https://agentpost.tools/docs/platform/reference/projects#the-project-object).",
            "schema": {
              "type": "string"
            },
            "example": "prj_01JDKYC5RZKAFFK3K2ENNC1ZTK"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "keys": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Key"
                      }
                    }
                  },
                  "required": ["keys"],
                  "additionalProperties": false
                },
                "example": {
                  "keys": [
                    {
                      "id": "key_01JDZ11YP80FXYTCSE1CE31KM0",
                      "projectId": "prj_01JDKYC5RZKAFFK3K2ENNC1ZTK",
                      "environment": "dev",
                      "kind": "secret",
                      "name": "server",
                      "prefix": "sk_test_4f1c9a2e7b3d",
                      "status": "active",
                      "createdAt": "2026-11-13T09:30:00.000Z"
                    },
                    {
                      "id": "key_01JDMK0FRK03N1Z9T2JSHY4BPP",
                      "projectId": "prj_01JDKYC5RZKAFFK3K2ENNC1ZTK",
                      "environment": "dev",
                      "kind": "publishable",
                      "name": "web",
                      "prefix": "pk_test_8d2f6a1c0e9b",
                      "key": "pk_test_8d2f6a1c0e9b",
                      "allowedOrigins": [
                        "http://localhost:5173",
                        "https://app.example.com"
                      ],
                      "allowNativeApps": false,
                      "status": "active",
                      "createdAt": "2026-11-13T09:30:00.000Z"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/errors#unauthenticated) or [`secret_key_invalid`](https://agentpost.tools/docs/errors#secret_key_invalid).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated", "secret_key_invalid"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/errors#forbidden) or [`origin_not_allowed`](https://agentpost.tools/docs/errors#origin_not_allowed).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden", "origin_not_allowed"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "503": {
            "description": "Service Unavailable, with `error.code` [`not_ready`](https://agentpost.tools/docs/errors#not_ready).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_ready"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "keys.issue",
        "summary": "Issue a key",
        "description": "Issues a secret key, or a publishable key with the origins it works from and whether native apps may use it.\n\n- **Who may call:** A member of the workspace, with its API key; a member of the workspace, with its session; or a delegate, with its delegated token.\n- **Access:** The caller holds `apoa.key:issue` in the project's workspace.",
        "tags": ["Keys"],
        "externalDocs": {
          "description": "Issue a key, in the API reference",
          "url": "https://agentpost.tools/docs/platform/reference/keys#issue-a-key"
        },
        "security": [
          {
            "apiKey": []
          },
          {
            "platformSession": []
          },
          {
            "delegatedToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "A project ID, `prj_…`. The `id` of a [`Project`](https://agentpost.tools/docs/platform/reference/projects#the-project-object).",
            "schema": {
              "type": "string"
            },
            "example": "prj_01JDKYC5RZKAFFK3K2ENNC1ZTK"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "What it is for, such as `render`"
                  },
                  "environment": {
                    "type": "string",
                    "enum": ["dev", "prd"],
                    "description": "`dev` for development and tests, `prd` for production"
                  },
                  "kind": {
                    "default": "secret",
                    "type": "string",
                    "enum": ["secret", "publishable"]
                  },
                  "allowedOrigins": {
                    "description": "A publishable key only: each origin as a browser sends it, such as `https://app.example.com`. No path or wildcard. `http` works only on `localhost`, `127.0.0.1`, or `[::1]`, for a `dev` key. Required, with 1 to 20 origins, unless the key allows native apps, when it may be left out or empty",
                    "maxItems": 20,
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "allowNativeApps": {
                    "default": false,
                    "description": "A publishable key only: `true` lets a native app, such as an iOS, Android, or Expo app, use the key with no `Origin` header. A request that sends an `Origin` is still held to `allowedOrigins`",
                    "type": "boolean"
                  }
                },
                "required": ["name", "environment"],
                "additionalProperties": false
              },
              "example": {
                "name": "server",
                "environment": "dev"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "key": {
                      "type": "string",
                      "description": "The key itself. A secret key is shown once"
                    },
                    "record": {
                      "$ref": "#/components/schemas/Key"
                    }
                  },
                  "required": ["key", "record"],
                  "additionalProperties": false
                },
                "example": {
                  "key": "sk_test_…",
                  "record": {
                    "id": "key_01JDZ11YP80FXYTCSE1CE31KM0",
                    "projectId": "prj_01JDKYC5RZKAFFK3K2ENNC1ZTK",
                    "environment": "dev",
                    "kind": "secret",
                    "name": "server",
                    "prefix": "sk_test_4f1c9a2e7b3d",
                    "status": "active",
                    "createdAt": "2026-11-13T09:30:00.000Z"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/errors#unauthenticated) or [`secret_key_invalid`](https://agentpost.tools/docs/errors#secret_key_invalid).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated", "secret_key_invalid"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/errors#forbidden) or [`origin_not_allowed`](https://agentpost.tools/docs/errors#origin_not_allowed).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden", "origin_not_allowed"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "503": {
            "description": "Service Unavailable, with `error.code` [`not_ready`](https://agentpost.tools/docs/errors#not_ready).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_ready"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/v1/projects/{id}/keys/{keyId}/rotate": {
      "post": {
        "operationId": "keys.rotate",
        "summary": "Rotate a key",
        "description": "Replaces a secret key with a new one of the same name and environment. Set `grace` to say how long the old key keeps working. The answer gives its `graceEndsAt` in `previous`. A grace of `0s` stops the old key at once and needs the key's name as confirmation. To replace a publishable key, issue a new one and revoke the old one.\n\n- **Who may call:** A member of the workspace, with its API key; a member of the workspace, with its session; or a delegate, with its delegated token.\n- **Access:** The caller holds `apoa.key:rotate` in the project's workspace.",
        "tags": ["Keys"],
        "externalDocs": {
          "description": "Rotate a key, in the API reference",
          "url": "https://agentpost.tools/docs/platform/reference/keys#rotate-a-key"
        },
        "security": [
          {
            "apiKey": []
          },
          {
            "platformSession": []
          },
          {
            "delegatedToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "A project ID, `prj_…`. The `id` of a [`Project`](https://agentpost.tools/docs/platform/reference/projects#the-project-object).",
            "schema": {
              "type": "string"
            },
            "example": "prj_01JDKYC5RZKAFFK3K2ENNC1ZTK"
          },
          {
            "name": "keyId",
            "in": "path",
            "required": true,
            "description": "A key ID, `key_…`. The `id` of a [`Key`](https://agentpost.tools/docs/platform/reference/keys#the-key-object).",
            "schema": {
              "type": "string"
            },
            "example": "key_01JDZ11YP80FXYTCSE1CE31KM0"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "grace": {
                    "type": "string",
                    "description": "A duration from `0s` to `7d`"
                  },
                  "confirm": {
                    "description": "The key's name, required when `grace` is `0s`",
                    "type": "string"
                  }
                },
                "required": ["grace"],
                "additionalProperties": false
              },
              "example": {
                "grace": "1h"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "key": {
                      "type": "string",
                      "description": "The new key. Shown once"
                    },
                    "record": {
                      "$ref": "#/components/schemas/Key"
                    },
                    "previous": {
                      "$ref": "#/components/schemas/Key"
                    }
                  },
                  "required": ["key", "record", "previous"],
                  "additionalProperties": false
                },
                "example": {
                  "key": "sk_test_…",
                  "record": {
                    "id": "key_01JDZ6AJ7K56PD5A8JS97ZWT3G",
                    "projectId": "prj_01JDKYC5RZKAFFK3K2ENNC1ZTK",
                    "environment": "dev",
                    "kind": "secret",
                    "name": "server",
                    "prefix": "sk_test_9b7e2d4c1a6f",
                    "status": "active",
                    "createdAt": "2026-11-13T09:30:00.000Z",
                    "rotatedFrom": "key_01JDZ11YP80FXYTCSE1CE31KM0"
                  },
                  "previous": {
                    "id": "key_01JDZ11YP80FXYTCSE1CE31KM0",
                    "projectId": "prj_01JDKYC5RZKAFFK3K2ENNC1ZTK",
                    "environment": "dev",
                    "kind": "secret",
                    "name": "server",
                    "prefix": "sk_test_4f1c9a2e7b3d",
                    "status": "grace",
                    "createdAt": "2026-11-13T09:30:00.000Z",
                    "graceEndsAt": "2026-11-13T10:30:00.000Z",
                    "replacedBy": "key_01JDZ6AJ7K56PD5A8JS97ZWT3G"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`confirmation_required`](https://agentpost.tools/docs/errors#confirmation_required) or [`invalid_request`](https://agentpost.tools/docs/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": [
                                "confirmation_required",
                                "invalid_request"
                              ]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/errors#unauthenticated) or [`secret_key_invalid`](https://agentpost.tools/docs/errors#secret_key_invalid).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated", "secret_key_invalid"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/errors#forbidden) or [`origin_not_allowed`](https://agentpost.tools/docs/errors#origin_not_allowed).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden", "origin_not_allowed"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Conflict, with `error.code` [`conflict`](https://agentpost.tools/docs/errors#conflict).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["conflict"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "503": {
            "description": "Service Unavailable, with `error.code` [`not_ready`](https://agentpost.tools/docs/errors#not_ready).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_ready"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/v1/projects/{id}/keys/{keyId}": {
      "patch": {
        "operationId": "keys.update",
        "summary": "Update a publishable key",
        "description": "Changes who may use a publishable key: its allowed origins, whether native apps may use it, or both. A field left out keeps its value, and the key must still allow an origin or native apps. The change takes effect on the next request, so the site or app the key is built into needs no new release.\n\n- **Who may call:** A member of the workspace, with its API key; a member of the workspace, with its session; or a delegate, with its delegated token.\n- **Access:** The caller holds `apoa.key:issue` in the project's workspace.",
        "tags": ["Keys"],
        "externalDocs": {
          "description": "Update a publishable key, in the API reference",
          "url": "https://agentpost.tools/docs/platform/reference/keys#update-a-publishable-key"
        },
        "security": [
          {
            "apiKey": []
          },
          {
            "platformSession": []
          },
          {
            "delegatedToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "A project ID, `prj_…`. The `id` of a [`Project`](https://agentpost.tools/docs/platform/reference/projects#the-project-object).",
            "schema": {
              "type": "string"
            },
            "example": "prj_01JDKYC5RZKAFFK3K2ENNC1ZTK"
          },
          {
            "name": "keyId",
            "in": "path",
            "required": true,
            "description": "A key ID, `key_…`. The `id` of a [`Key`](https://agentpost.tools/docs/platform/reference/keys#the-key-object).",
            "schema": {
              "type": "string"
            },
            "example": "key_01JDMK0FRK03N1Z9T2JSHY4BPP"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "allowedOrigins": {
                    "description": "The whole new list. Empty only for a key that allows native apps",
                    "maxItems": 20,
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "allowNativeApps": {
                    "description": "Whether a native app, which sends no `Origin`, may use the key",
                    "type": "boolean"
                  }
                },
                "additionalProperties": false
              },
              "example": {
                "allowedOrigins": ["https://app.example.com"],
                "allowNativeApps": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "record": {
                      "$ref": "#/components/schemas/Key"
                    }
                  },
                  "required": ["record"],
                  "additionalProperties": false
                },
                "example": {
                  "record": {
                    "id": "key_01JDMK0FRK03N1Z9T2JSHY4BPP",
                    "projectId": "prj_01JDKYC5RZKAFFK3K2ENNC1ZTK",
                    "environment": "dev",
                    "kind": "publishable",
                    "name": "web",
                    "prefix": "pk_test_8d2f6a1c0e9b",
                    "key": "pk_test_8d2f6a1c0e9b",
                    "allowedOrigins": ["https://app.example.com"],
                    "allowNativeApps": true,
                    "status": "active",
                    "createdAt": "2026-11-13T09:30:00.000Z"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/errors#unauthenticated) or [`secret_key_invalid`](https://agentpost.tools/docs/errors#secret_key_invalid).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated", "secret_key_invalid"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/errors#forbidden) or [`origin_not_allowed`](https://agentpost.tools/docs/errors#origin_not_allowed).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden", "origin_not_allowed"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Conflict, with `error.code` [`conflict`](https://agentpost.tools/docs/errors#conflict).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["conflict"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "503": {
            "description": "Service Unavailable, with `error.code` [`not_ready`](https://agentpost.tools/docs/errors#not_ready).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_ready"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "keys.revoke",
        "summary": "Revoke a key",
        "description": "Revokes a key at once. Every request with it fails from then on, and so do user tokens it minted.\n\n- **Who may call:** A member of the workspace, with its API key; a member of the workspace, with its session; or a delegate, with its delegated token.\n- **Access:** The caller holds `apoa.key:revoke` in the project's workspace.",
        "tags": ["Keys"],
        "externalDocs": {
          "description": "Revoke a key, in the API reference",
          "url": "https://agentpost.tools/docs/platform/reference/keys#revoke-a-key"
        },
        "security": [
          {
            "apiKey": []
          },
          {
            "platformSession": []
          },
          {
            "delegatedToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "A project ID, `prj_…`. The `id` of a [`Project`](https://agentpost.tools/docs/platform/reference/projects#the-project-object).",
            "schema": {
              "type": "string"
            },
            "example": "prj_01JDKYC5RZKAFFK3K2ENNC1ZTK"
          },
          {
            "name": "keyId",
            "in": "path",
            "required": true,
            "description": "A key ID, `key_…`. The `id` of a [`Key`](https://agentpost.tools/docs/platform/reference/keys#the-key-object).",
            "schema": {
              "type": "string"
            },
            "example": "key_01JDZ11YP80FXYTCSE1CE31KM0"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "record": {
                      "$ref": "#/components/schemas/Key"
                    }
                  },
                  "required": ["record"],
                  "additionalProperties": false
                },
                "example": {
                  "record": {
                    "id": "key_01JDZ11YP80FXYTCSE1CE31KM0",
                    "projectId": "prj_01JDKYC5RZKAFFK3K2ENNC1ZTK",
                    "environment": "dev",
                    "kind": "secret",
                    "name": "server",
                    "prefix": "sk_test_4f1c9a2e7b3d",
                    "status": "revoked",
                    "createdAt": "2026-11-13T09:30:00.000Z",
                    "revokedAt": "2026-11-13T09:30:00.000Z"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/errors#unauthenticated) or [`secret_key_invalid`](https://agentpost.tools/docs/errors#secret_key_invalid).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated", "secret_key_invalid"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/errors#forbidden) or [`origin_not_allowed`](https://agentpost.tools/docs/errors#origin_not_allowed).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden", "origin_not_allowed"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "503": {
            "description": "Service Unavailable, with `error.code` [`not_ready`](https://agentpost.tools/docs/errors#not_ready).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_ready"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/v1/workspaces/{workspaceId}/keys": {
      "get": {
        "operationId": "workspaceKeys.list",
        "summary": "List workspace keys",
        "description": "Every key of the workspace, in both environments, oldest first, revoked ones included. Never a secret.\n\n- **Who may call:** A member of the workspace, with its API key; a member of the workspace, with its session; or a delegate, with its delegated token.\n- **Access:** The caller holds `apoa.workspace_key:view` in the workspace. A workspace the caller has no part in is not found.",
        "tags": ["Keys"],
        "externalDocs": {
          "description": "List workspace keys, in the API reference",
          "url": "https://agentpost.tools/docs/platform/reference/keys#list-workspace-keys"
        },
        "security": [
          {
            "apiKey": []
          },
          {
            "platformSession": []
          },
          {
            "delegatedToken": []
          }
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "in": "path",
            "required": true,
            "description": "A workspace ID, `wsp_…`. It is `workspace.id` in the answer to [Sign up](https://agentpost.tools/docs/platform/reference/workspaces#sign-up).",
            "schema": {
              "type": "string"
            },
            "example": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "keys": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/WorkspaceKey"
                      }
                    }
                  },
                  "required": ["keys"],
                  "additionalProperties": false
                },
                "example": {
                  "keys": [
                    {
                      "id": "wkey_01JDZ8M3Q4R5S6T7V8W9X0Y1Z2",
                      "workspaceId": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62",
                      "environment": "prd",
                      "name": "analytics",
                      "permissions": ["events:read"],
                      "prefix": "wk_live_3c8e1f5a9d27",
                      "status": "active",
                      "createdAt": "2026-11-13T09:30:00.000Z",
                      "lastUsedAt": "2026-11-13T09:30:00.000Z"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/errors#unauthenticated) or [`secret_key_invalid`](https://agentpost.tools/docs/errors#secret_key_invalid).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated", "secret_key_invalid"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/errors#forbidden) or [`origin_not_allowed`](https://agentpost.tools/docs/errors#origin_not_allowed).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden", "origin_not_allowed"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "503": {
            "description": "Service Unavailable, with `error.code` [`not_ready`](https://agentpost.tools/docs/errors#not_ready).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_ready"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "workspaceKeys.issue",
        "summary": "Issue a workspace key",
        "description": "Issues a workspace key, which reads every project of the workspace in one environment, those added later included, within its permissions. Its permissions are fixed when it is issued; to change them, issue another key. The workspace's owners get an email.\n\n- **Who may call:** A member of the workspace, with its API key; a member of the workspace, with its session; or a delegate, with its delegated token.\n- **Access:** The caller holds `apoa.workspace_key:issue` in the workspace. A workspace the caller has no part in is not found.",
        "tags": ["Keys"],
        "externalDocs": {
          "description": "Issue a workspace key, in the API reference",
          "url": "https://agentpost.tools/docs/platform/reference/keys#issue-a-workspace-key"
        },
        "security": [
          {
            "apiKey": []
          },
          {
            "platformSession": []
          },
          {
            "delegatedToken": []
          }
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "in": "path",
            "required": true,
            "description": "A workspace ID, `wsp_…`. It is `workspace.id` in the answer to [Sign up](https://agentpost.tools/docs/platform/reference/workspaces#sign-up).",
            "schema": {
              "type": "string"
            },
            "example": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "What it is for, such as `analytics`"
                  },
                  "environment": {
                    "type": "string",
                    "enum": ["dev", "prd"],
                    "description": "`dev` for development and tests, `prd` for production"
                  },
                  "permissions": {
                    "minItems": 1,
                    "type": "array",
                    "items": {
                      "type": "string",
                      "enum": ["events:read"]
                    },
                    "description": "What the key may do, one or more"
                  },
                  "expiresAt": {
                    "description": "When the key stops working, after now. Left out, it works until it is revoked",
                    "type": "string",
                    "format": "date-time"
                  }
                },
                "required": ["name", "environment", "permissions"],
                "additionalProperties": false
              },
              "example": {
                "name": "analytics",
                "environment": "prd",
                "permissions": ["events:read"]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "key": {
                      "type": "string",
                      "description": "The key itself. Shown once"
                    },
                    "record": {
                      "$ref": "#/components/schemas/WorkspaceKey"
                    }
                  },
                  "required": ["key", "record"],
                  "additionalProperties": false
                },
                "example": {
                  "key": "wk_live_…",
                  "record": {
                    "id": "wkey_01JDZ8M3Q4R5S6T7V8W9X0Y1Z2",
                    "workspaceId": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62",
                    "environment": "prd",
                    "name": "analytics",
                    "permissions": ["events:read"],
                    "prefix": "wk_live_3c8e1f5a9d27",
                    "status": "active",
                    "createdAt": "2026-11-13T09:30:00.000Z"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/errors#unauthenticated) or [`secret_key_invalid`](https://agentpost.tools/docs/errors#secret_key_invalid).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated", "secret_key_invalid"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/errors#forbidden) or [`origin_not_allowed`](https://agentpost.tools/docs/errors#origin_not_allowed).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden", "origin_not_allowed"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "503": {
            "description": "Service Unavailable, with `error.code` [`not_ready`](https://agentpost.tools/docs/errors#not_ready).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_ready"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/v1/workspaces/{workspaceId}/keys/{workspaceKeyId}/rotate": {
      "post": {
        "operationId": "workspaceKeys.rotate",
        "summary": "Rotate a workspace key",
        "description": "Replaces a workspace key with a new one of the same name, environment, permissions, and `expiresAt`. Set `grace` to say how long the old key keeps working. The answer gives its `graceEndsAt` in `previous`. A grace of `0s` stops the old key at once and needs the key's name as confirmation.\n\n- **Who may call:** A member of the workspace, with its API key; a member of the workspace, with its session; or a delegate, with its delegated token.\n- **Access:** The caller holds `apoa.workspace_key:rotate` in the workspace. A workspace the caller has no part in is not found.",
        "tags": ["Keys"],
        "externalDocs": {
          "description": "Rotate a workspace key, in the API reference",
          "url": "https://agentpost.tools/docs/platform/reference/keys#rotate-a-workspace-key"
        },
        "security": [
          {
            "apiKey": []
          },
          {
            "platformSession": []
          },
          {
            "delegatedToken": []
          }
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "in": "path",
            "required": true,
            "description": "A workspace ID, `wsp_…`. It is `workspace.id` in the answer to [Sign up](https://agentpost.tools/docs/platform/reference/workspaces#sign-up).",
            "schema": {
              "type": "string"
            },
            "example": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62"
          },
          {
            "name": "workspaceKeyId",
            "in": "path",
            "required": true,
            "description": "A workspace key ID, `wkey_…`. The `id` of a [`WorkspaceKey`](https://agentpost.tools/docs/platform/reference/keys#the-workspacekey-object).",
            "schema": {
              "type": "string"
            },
            "example": "wkey_01JDZ8M3Q4R5S6T7V8W9X0Y1Z2"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "grace": {
                    "type": "string",
                    "description": "A duration from `0s` to `7d`"
                  },
                  "confirm": {
                    "description": "The key's name, required when `grace` is `0s`",
                    "type": "string"
                  }
                },
                "required": ["grace"],
                "additionalProperties": false
              },
              "example": {
                "grace": "1h"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "key": {
                      "type": "string",
                      "description": "The new key. Shown once"
                    },
                    "record": {
                      "$ref": "#/components/schemas/WorkspaceKey"
                    },
                    "previous": {
                      "$ref": "#/components/schemas/WorkspaceKey"
                    }
                  },
                  "required": ["key", "record", "previous"],
                  "additionalProperties": false
                },
                "example": {
                  "key": "wk_live_…",
                  "record": {
                    "id": "wkey_01JDZ9N4R5S6T7V8W9X0Y1Z2A3",
                    "workspaceId": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62",
                    "environment": "prd",
                    "name": "analytics",
                    "permissions": ["events:read"],
                    "prefix": "wk_live_7a2d9e4b1c6f",
                    "status": "active",
                    "createdAt": "2026-11-13T09:30:00.000Z",
                    "rotatedFrom": "wkey_01JDZ8M3Q4R5S6T7V8W9X0Y1Z2"
                  },
                  "previous": {
                    "id": "wkey_01JDZ8M3Q4R5S6T7V8W9X0Y1Z2",
                    "workspaceId": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62",
                    "environment": "prd",
                    "name": "analytics",
                    "permissions": ["events:read"],
                    "prefix": "wk_live_3c8e1f5a9d27",
                    "status": "grace",
                    "createdAt": "2026-11-13T09:30:00.000Z",
                    "lastUsedAt": "2026-11-13T09:30:00.000Z",
                    "graceEndsAt": "2026-11-13T10:30:00.000Z",
                    "replacedBy": "wkey_01JDZ9N4R5S6T7V8W9X0Y1Z2A3"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`confirmation_required`](https://agentpost.tools/docs/errors#confirmation_required) or [`invalid_request`](https://agentpost.tools/docs/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": [
                                "confirmation_required",
                                "invalid_request"
                              ]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/errors#unauthenticated) or [`secret_key_invalid`](https://agentpost.tools/docs/errors#secret_key_invalid).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated", "secret_key_invalid"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/errors#forbidden) or [`origin_not_allowed`](https://agentpost.tools/docs/errors#origin_not_allowed).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden", "origin_not_allowed"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Conflict, with `error.code` [`conflict`](https://agentpost.tools/docs/errors#conflict).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["conflict"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "503": {
            "description": "Service Unavailable, with `error.code` [`not_ready`](https://agentpost.tools/docs/errors#not_ready).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_ready"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/v1/workspaces/{workspaceId}/keys/{workspaceKeyId}": {
      "delete": {
        "operationId": "workspaceKeys.revoke",
        "summary": "Revoke a workspace key",
        "description": "Revokes a workspace key at once. Every new request with it fails from then on, and a live tail it opened stops within two heartbeats, 30 seconds by default. A revoked key can't be restored.\n\n- **Who may call:** A member of the workspace, with its API key; a member of the workspace, with its session; or a delegate, with its delegated token.\n- **Access:** The caller holds `apoa.workspace_key:revoke` in the workspace. A workspace the caller has no part in is not found.",
        "tags": ["Keys"],
        "externalDocs": {
          "description": "Revoke a workspace key, in the API reference",
          "url": "https://agentpost.tools/docs/platform/reference/keys#revoke-a-workspace-key"
        },
        "security": [
          {
            "apiKey": []
          },
          {
            "platformSession": []
          },
          {
            "delegatedToken": []
          }
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "in": "path",
            "required": true,
            "description": "A workspace ID, `wsp_…`. It is `workspace.id` in the answer to [Sign up](https://agentpost.tools/docs/platform/reference/workspaces#sign-up).",
            "schema": {
              "type": "string"
            },
            "example": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62"
          },
          {
            "name": "workspaceKeyId",
            "in": "path",
            "required": true,
            "description": "A workspace key ID, `wkey_…`. The `id` of a [`WorkspaceKey`](https://agentpost.tools/docs/platform/reference/keys#the-workspacekey-object).",
            "schema": {
              "type": "string"
            },
            "example": "wkey_01JDZ8M3Q4R5S6T7V8W9X0Y1Z2"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "record": {
                      "$ref": "#/components/schemas/WorkspaceKey"
                    }
                  },
                  "required": ["record"],
                  "additionalProperties": false
                },
                "example": {
                  "record": {
                    "id": "wkey_01JDZ8M3Q4R5S6T7V8W9X0Y1Z2",
                    "workspaceId": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62",
                    "environment": "prd",
                    "name": "analytics",
                    "permissions": ["events:read"],
                    "prefix": "wk_live_3c8e1f5a9d27",
                    "status": "revoked",
                    "createdAt": "2026-11-13T09:30:00.000Z",
                    "lastUsedAt": "2026-11-13T09:30:00.000Z",
                    "revokedAt": "2026-11-13T09:30:00.000Z"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/errors#unauthenticated) or [`secret_key_invalid`](https://agentpost.tools/docs/errors#secret_key_invalid).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated", "secret_key_invalid"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/errors#forbidden) or [`origin_not_allowed`](https://agentpost.tools/docs/errors#origin_not_allowed).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden", "origin_not_allowed"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "503": {
            "description": "Service Unavailable, with `error.code` [`not_ready`](https://agentpost.tools/docs/errors#not_ready).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_ready"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/v1/workspace-keys/current": {
      "get": {
        "operationId": "workspaceKeys.current",
        "summary": "Get the current workspace key",
        "description": "What a workspace key reaches now: the key, and its workspace's projects that it can read, those added after it was issued included. Name one of them in the `x-agentpost-project` header of each request the key makes to a service, such as `GET /v1/events/events`.\n\n- **Who may call:** A workspace key.\n- **Access:** The workspace key itself, `wk_test_…` or `wk_live_…`. Any other credential is refused.",
        "tags": ["Keys"],
        "externalDocs": {
          "description": "Get the current workspace key, in the API reference",
          "url": "https://agentpost.tools/docs/platform/reference/keys#get-the-current-workspace-key"
        },
        "security": [
          {
            "workspaceKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "key": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "description": "A workspace key ID, `wkey_…`"
                        },
                        "name": {
                          "type": "string"
                        },
                        "workspaceId": {
                          "type": "string"
                        },
                        "environment": {
                          "type": "string",
                          "enum": ["dev", "prd"],
                          "description": "`dev` for development and tests, `prd` for production"
                        },
                        "permissions": {
                          "type": "array",
                          "items": {
                            "type": "string",
                            "enum": ["events:read"]
                          }
                        },
                        "status": {
                          "type": "string",
                          "enum": ["active", "grace", "expired", "revoked"],
                          "description": "Only keys with an `active` or `grace` status work. After rotation, the old key has `grace` until `graceEndsAt`, or until `expiresAt` if it comes first. A key becomes `expired` at either deadline"
                        },
                        "graceEndsAt": {
                          "description": "After a rotation: when this key stops working",
                          "type": "string",
                          "format": "date-time"
                        },
                        "expiresAt": {
                          "description": "When it stops working, if it was issued to expire",
                          "type": "string",
                          "format": "date-time"
                        }
                      },
                      "required": [
                        "id",
                        "name",
                        "workspaceId",
                        "environment",
                        "permissions",
                        "status"
                      ],
                      "additionalProperties": false
                    },
                    "projects": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "description": "A project ID, `prj_…`"
                          },
                          "name": {
                            "type": "string"
                          }
                        },
                        "required": ["id", "name"],
                        "additionalProperties": false
                      },
                      "description": "The workspace's projects, oldest first, that aren't deleted and adopted a service the key's permissions read, as of this call"
                    }
                  },
                  "required": ["key", "projects"],
                  "additionalProperties": false
                },
                "example": {
                  "key": {
                    "id": "wkey_01JDZ8M3Q4R5S6T7V8W9X0Y1Z2",
                    "name": "analytics",
                    "workspaceId": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62",
                    "environment": "prd",
                    "permissions": ["events:read"],
                    "status": "active"
                  },
                  "projects": [
                    {
                      "id": "prj_01JE2T7WQ8M4X6B1C9D3F5G7H0",
                      "name": "Support desk"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/errors#unauthenticated) or [`secret_key_invalid`](https://agentpost.tools/docs/errors#secret_key_invalid).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated", "secret_key_invalid"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/errors#forbidden) or [`origin_not_allowed`](https://agentpost.tools/docs/errors#origin_not_allowed).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden", "origin_not_allowed"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "503": {
            "description": "Service Unavailable, with `error.code` [`not_ready`](https://agentpost.tools/docs/errors#not_ready).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_ready"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/v1/projects/{id}/sending-domain": {
      "get": {
        "operationId": "sendingDomain.get",
        "summary": "Get the sending domain",
        "description": "The project's sending domain and the sender in force. A pending domain is checked again first, so polling this shows when it verifies.\n\n- **Who may call:** A member of the workspace, with its API key; a member of the workspace, with its session; or a delegate, with its delegated token.\n- **Access:** The caller holds `apoa.project:view` in the project's workspace.",
        "tags": ["Sending domain"],
        "externalDocs": {
          "description": "Get the sending domain, in the API reference",
          "url": "https://agentpost.tools/docs/platform/reference/sending-domain#get-the-sending-domain"
        },
        "security": [
          {
            "apiKey": []
          },
          {
            "platformSession": []
          },
          {
            "delegatedToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "A project ID, `prj_…`. The `id` of a [`Project`](https://agentpost.tools/docs/platform/reference/projects#the-project-object).",
            "schema": {
              "type": "string"
            },
            "example": "prj_01JDKYC5RZKAFFK3K2ENNC1ZTK"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SendingDomainState"
                },
                "example": {
                  "projectId": "prj_01JDKYC5RZKAFFK3K2ENNC1ZTK",
                  "sendingDomain": {
                    "domain": "example.com",
                    "address": "no-reply@example.com",
                    "status": "pending",
                    "waitingOn": ["DKIM is PENDING"],
                    "records": [
                      {
                        "type": "CNAME",
                        "name": "abc123._domainkey.example.com",
                        "value": "abc123.dkim.amazonses.com"
                      },
                      {
                        "type": "MX",
                        "name": "mail.example.com",
                        "value": "10 feedback-smtp.us-east-2.amazonses.com"
                      },
                      {
                        "type": "TXT",
                        "name": "mail.example.com",
                        "value": "v=spf1 include:amazonses.com ~all"
                      }
                    ],
                    "recommended": [
                      {
                        "type": "TXT",
                        "name": "_dmarc.example.com",
                        "value": "v=DMARC1; p=none;"
                      }
                    ],
                    "requestedAt": "2026-11-13T09:30:00.000Z",
                    "checkedAt": "2026-11-13T09:30:00.000Z",
                    "nextCheckAt": "2026-11-13T09:35:00.000Z"
                  },
                  "sender": null
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/errors#unauthenticated) or [`secret_key_invalid`](https://agentpost.tools/docs/errors#secret_key_invalid).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated", "secret_key_invalid"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/errors#forbidden) or [`origin_not_allowed`](https://agentpost.tools/docs/errors#origin_not_allowed).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden", "origin_not_allowed"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "503": {
            "description": "Service Unavailable, with `error.code` [`unavailable`](https://agentpost.tools/docs/errors#unavailable) or [`not_ready`](https://agentpost.tools/docs/errors#not_ready).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unavailable", "not_ready"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      },
      "put": {
        "operationId": "sendingDomain.set",
        "summary": "Set the sending domain",
        "description": "Adds a domain to send from, or changes the address. The answer lists the DNS records to add. While a new domain is pending, the current sender keeps sending.\n\n- **Who may call:** A member of the workspace, with its API key; a member of the workspace, with its session; or a delegate, with its delegated token.\n- **Access:** The caller holds `apoa.project:update` in the project's workspace.",
        "tags": ["Sending domain"],
        "externalDocs": {
          "description": "Set the sending domain, in the API reference",
          "url": "https://agentpost.tools/docs/platform/reference/sending-domain#set-the-sending-domain"
        },
        "security": [
          {
            "apiKey": []
          },
          {
            "platformSession": []
          },
          {
            "delegatedToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "A project ID, `prj_…`. The `id` of a [`Project`](https://agentpost.tools/docs/platform/reference/projects#the-project-object).",
            "schema": {
              "type": "string"
            },
            "example": "prj_01JDKYC5RZKAFFK3K2ENNC1ZTK"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "domain": {
                    "type": "string",
                    "description": "Such as `example.com`"
                  },
                  "address": {
                    "description": "At the domain. Default `no-reply@<domain>`",
                    "type": "string"
                  }
                },
                "required": ["domain"],
                "additionalProperties": false
              },
              "example": {
                "domain": "example.com"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SendingDomainState"
                },
                "example": {
                  "projectId": "prj_01JDKYC5RZKAFFK3K2ENNC1ZTK",
                  "sendingDomain": {
                    "domain": "example.com",
                    "address": "no-reply@example.com",
                    "status": "pending",
                    "waitingOn": ["DKIM is PENDING"],
                    "records": [
                      {
                        "type": "CNAME",
                        "name": "abc123._domainkey.example.com",
                        "value": "abc123.dkim.amazonses.com"
                      },
                      {
                        "type": "MX",
                        "name": "mail.example.com",
                        "value": "10 feedback-smtp.us-east-2.amazonses.com"
                      },
                      {
                        "type": "TXT",
                        "name": "mail.example.com",
                        "value": "v=spf1 include:amazonses.com ~all"
                      }
                    ],
                    "recommended": [
                      {
                        "type": "TXT",
                        "name": "_dmarc.example.com",
                        "value": "v=DMARC1; p=none;"
                      }
                    ],
                    "requestedAt": "2026-11-13T09:30:00.000Z",
                    "checkedAt": "2026-11-13T09:30:00.000Z",
                    "nextCheckAt": "2026-11-13T09:35:00.000Z"
                  },
                  "sender": null
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/errors#unauthenticated) or [`secret_key_invalid`](https://agentpost.tools/docs/errors#secret_key_invalid).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated", "secret_key_invalid"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/errors#forbidden) or [`origin_not_allowed`](https://agentpost.tools/docs/errors#origin_not_allowed).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden", "origin_not_allowed"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Conflict, with `error.code` [`conflict`](https://agentpost.tools/docs/errors#conflict).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["conflict"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "503": {
            "description": "Service Unavailable, with `error.code` [`unavailable`](https://agentpost.tools/docs/errors#unavailable) or [`not_ready`](https://agentpost.tools/docs/errors#not_ready).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unavailable", "not_ready"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "sendingDomain.remove",
        "summary": "Remove the sending domain",
        "description": "Removes the sending domain. The project sends no email, sign-in codes included, until another domain verifies, so it needs the domain as confirmation.\n\n- **Who may call:** A member of the workspace, with its API key; a member of the workspace, with its session; or a delegate, with its delegated token.\n- **Access:** The caller holds `apoa.project:update` in the project's workspace.",
        "tags": ["Sending domain"],
        "externalDocs": {
          "description": "Remove the sending domain, in the API reference",
          "url": "https://agentpost.tools/docs/platform/reference/sending-domain#remove-the-sending-domain"
        },
        "security": [
          {
            "apiKey": []
          },
          {
            "platformSession": []
          },
          {
            "delegatedToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "A project ID, `prj_…`. The `id` of a [`Project`](https://agentpost.tools/docs/platform/reference/projects#the-project-object).",
            "schema": {
              "type": "string"
            },
            "example": "prj_01JDKYC5RZKAFFK3K2ENNC1ZTK"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "confirm": {
                    "type": "string",
                    "description": "The domain"
                  }
                },
                "required": ["confirm"],
                "additionalProperties": false
              },
              "example": {
                "confirm": "example.com"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SendingDomainState"
                },
                "example": {
                  "projectId": "prj_01JDKYC5RZKAFFK3K2ENNC1ZTK",
                  "sendingDomain": null,
                  "sender": null
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`confirmation_required`](https://agentpost.tools/docs/errors#confirmation_required) or [`invalid_request`](https://agentpost.tools/docs/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": [
                                "confirmation_required",
                                "invalid_request"
                              ]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/errors#unauthenticated) or [`secret_key_invalid`](https://agentpost.tools/docs/errors#secret_key_invalid).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated", "secret_key_invalid"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/errors#forbidden) or [`origin_not_allowed`](https://agentpost.tools/docs/errors#origin_not_allowed).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden", "origin_not_allowed"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "503": {
            "description": "Service Unavailable, with `error.code` [`unavailable`](https://agentpost.tools/docs/errors#unavailable) or [`not_ready`](https://agentpost.tools/docs/errors#not_ready).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unavailable", "not_ready"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/v1/test-inbox": {
      "get": {
        "operationId": "testInbox.read",
        "summary": "Read the test inbox",
        "description": "The project's `dev` messages from the last hour, oldest first, at most the newest 100.\n\n- **Who may call:** Your server, with a secret key.\n- **Access:** The project's `dev` secret key, `sk_test_…`, only.",
        "tags": ["Test inbox"],
        "externalDocs": {
          "description": "Read the test inbox, in the API reference",
          "url": "https://agentpost.tools/docs/platform/reference/test-inbox#read-the-test-inbox"
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "parameters": [
          {
            "name": "to",
            "in": "query",
            "required": false,
            "description": "Only the messages to this address.",
            "schema": {
              "type": "string"
            },
            "example": "ada@example.test"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "messages": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/TestMessage"
                      }
                    }
                  },
                  "required": ["messages"],
                  "additionalProperties": false
                },
                "example": {
                  "messages": [
                    {
                      "template": "sign_in_code",
                      "to": "ada@example.test",
                      "data": {
                        "code": "123456"
                      },
                      "at": "2026-11-13T09:30:00.000Z"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/errors#unauthenticated) or [`secret_key_invalid`](https://agentpost.tools/docs/errors#secret_key_invalid).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated", "secret_key_invalid"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/errors#forbidden) or [`origin_not_allowed`](https://agentpost.tools/docs/errors#origin_not_allowed).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden", "origin_not_allowed"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "503": {
            "description": "Service Unavailable, with `error.code` [`not_ready`](https://agentpost.tools/docs/errors#not_ready).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_ready"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/v1/user-tokens": {
      "post": {
        "operationId": "userTokens.mint",
        "summary": "Mint a user token",
        "description": "Mints a user token. Your server, with its secret key, mints one for someone your own sign-in names. A principal signed in through the project's IdentityHound exchanges its session for one, which never outlives the session.\n\n- **Who may call:** Your server, with a secret key or a principal signed in to your project, with its IdentityHound session token.\n- **Access:** A secret key sends `externalId`. A session sends neither `externalId` nor `displayName`. A publishable key, an API key, a delegated token, and another user token are refused.",
        "tags": ["User tokens"],
        "externalDocs": {
          "description": "Mint a user token, in the API reference",
          "url": "https://agentpost.tools/docs/platform/reference/user-tokens#mint-a-user-token"
        },
        "security": [
          {
            "secretKey": []
          },
          {
            "sessionToken": []
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "externalId": {
                    "description": "With a secret key: your own ID for whoever signed in, such as `u_42`, with no spaces",
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "displayName": {
                    "description": "With a secret key: the name to show",
                    "type": "string",
                    "maxLength": 200
                  },
                  "expiresIn": {
                    "default": "15m",
                    "description": "How long it lasts, as a number and a unit, `s`, `m`, `h`, or `d`: `1m` to `1h`",
                    "type": "string"
                  }
                },
                "additionalProperties": false
              },
              "example": {
                "externalId": "u_42",
                "displayName": "Ada Lovelace"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "token": {
                      "type": "string",
                      "description": "The token itself. Shown once"
                    },
                    "userToken": {
                      "$ref": "#/components/schemas/UserToken"
                    }
                  },
                  "required": ["token", "userToken"],
                  "additionalProperties": false
                },
                "example": {
                  "token": "ut_test_…",
                  "userToken": {
                    "id": "utk_01JD5AR85PC3S4RK1JDEXWT2Y5",
                    "projectId": "prj_01JDKYC5RZKAFFK3K2ENNC1ZTK",
                    "environment": "dev",
                    "principalRef": "external:u_42",
                    "displayName": "Ada Lovelace",
                    "createdAt": "2026-11-13T09:30:00.000Z",
                    "expiresAt": "2026-11-13T09:45:00.000Z"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/errors#unauthenticated) or [`secret_key_invalid`](https://agentpost.tools/docs/errors#secret_key_invalid).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated", "secret_key_invalid"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/errors#forbidden) or [`origin_not_allowed`](https://agentpost.tools/docs/errors#origin_not_allowed).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden", "origin_not_allowed"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "503": {
            "description": "Service Unavailable, with `error.code` [`not_ready`](https://agentpost.tools/docs/errors#not_ready).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_ready"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/v1/user-tokens/current": {
      "get": {
        "operationId": "userTokens.current",
        "summary": "Get the current user token",
        "description": "Who a user token is for, so a page can show who is signed in.\n\n- **Who may call:** A user token.",
        "tags": ["User tokens"],
        "externalDocs": {
          "description": "Get the current user token, in the API reference",
          "url": "https://agentpost.tools/docs/platform/reference/user-tokens#get-the-current-user-token"
        },
        "security": [
          {
            "userToken": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "userToken": {
                      "$ref": "#/components/schemas/UserToken"
                    }
                  },
                  "required": ["userToken"],
                  "additionalProperties": false
                },
                "example": {
                  "userToken": {
                    "id": "utk_01JD5AR85PC3S4RK1JDEXWT2Y5",
                    "projectId": "prj_01JDKYC5RZKAFFK3K2ENNC1ZTK",
                    "environment": "dev",
                    "principalRef": "external:u_42",
                    "displayName": "Ada Lovelace",
                    "createdAt": "2026-11-13T09:30:00.000Z",
                    "expiresAt": "2026-11-13T09:45:00.000Z"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/errors#unauthenticated) or [`secret_key_invalid`](https://agentpost.tools/docs/errors#secret_key_invalid).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated", "secret_key_invalid"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/errors#forbidden) or [`origin_not_allowed`](https://agentpost.tools/docs/errors#origin_not_allowed).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden", "origin_not_allowed"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "503": {
            "description": "Service Unavailable, with `error.code` [`not_ready`](https://agentpost.tools/docs/errors#not_ready).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_ready"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Principal": {
        "description": "A principal: anyone who signs in to Agentpost, an agent or a human, as [IdentityHound’s principals](https://agentpost.tools/docs/identityhound/reference/principals) describes.",
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "A principal ID, `prn_…`"
          },
          "kind": {
            "description": "The kind it declared. Absent when it declared none",
            "type": "string",
            "enum": ["human", "agent", "service"]
          },
          "status": {
            "type": "string",
            "enum": ["active", "suspended", "deleted"]
          },
          "displayName": {
            "type": "string"
          },
          "avatarUrl": {
            "type": "string"
          },
          "projectRoles": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "description": {
            "type": "string"
          },
          "lastActiveAt": {
            "type": "string",
            "format": "date-time"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          },
          "createdBy": {
            "type": "string"
          },
          "externalRef": {
            "type": "string"
          },
          "metadata": {
            "type": "object",
            "propertyNames": {
              "type": "string"
            },
            "additionalProperties": {}
          }
        },
        "required": [
          "id",
          "status",
          "projectRoles",
          "createdAt",
          "updatedAt",
          "metadata"
        ],
        "additionalProperties": false,
        "examples": [
          {
            "id": "prn_01JDSJ41R3JK54F6RKD4Y3J1GF",
            "kind": "agent",
            "status": "active",
            "displayName": "Helper",
            "projectRoles": [],
            "lastActiveAt": "2026-11-12T15:00:00.000Z",
            "createdAt": "2026-11-12T15:00:00.000Z",
            "updatedAt": "2026-11-12T15:00:00.000Z",
            "metadata": {}
          }
        ]
      },
      "Workspace": {
        "description": "A workspace: the container of projects, keys, and members, and the project limit they count against.",
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "A workspace ID, `wsp_…`"
          },
          "name": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": ["active", "archived"]
          },
          "projects": {
            "type": "object",
            "properties": {
              "used": {
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              },
              "max": {
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              }
            },
            "required": ["used", "max"],
            "additionalProperties": false,
            "description": "How many projects the workspace holds, and may hold. Deleting a project frees its place"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": ["id", "name", "status", "projects", "createdAt"],
        "additionalProperties": false,
        "examples": [
          {
            "id": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62",
            "name": "My workspace",
            "status": "active",
            "projects": {
              "used": 1,
              "max": 100
            },
            "createdAt": "2026-11-12T15:00:00.000Z"
          }
        ]
      },
      "WorkspaceEvent": {
        "description": "One change to a workspace: what happened, who did it, and when.",
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "The event’s ID, the same for the same fact, such as `access.updated:key:rotated:key_…`"
          },
          "sequence": {
            "type": "integer",
            "minimum": 1,
            "maximum": 9007199254740991,
            "description": "Its place in the order of events. Pass the last one you read as `after`"
          },
          "type": {
            "type": "string",
            "description": "What happened, as `<category>.<verb>`, such as `access.created`. `data.kind` says to what"
          },
          "time": {
            "type": "string",
            "format": "date-time",
            "description": "When it happened"
          },
          "summary": {
            "type": "string",
            "description": "One line that says what happened"
          },
          "actor": {
            "type": "string",
            "description": "Who did it: `principal:<id>`, the delegate when a delegate acted, or `service:apoa` or `service:identityhound` when Agentpost made the change on its own, such as a sending domain check or an expiry"
          },
          "onBehalfOf": {
            "description": "The delegator, `principal:<id>`, when a delegate acted for it. Absent otherwise",
            "type": "string"
          },
          "data": {
            "type": "object",
            "propertyNames": {
              "type": "string"
            },
            "additionalProperties": {},
            "description": "The facts, by ID: `kind`, `workspaceId`, and the IDs and values the change is about, never a name, an email address, or a secret"
          }
        },
        "required": [
          "id",
          "sequence",
          "type",
          "time",
          "summary",
          "actor",
          "data"
        ],
        "additionalProperties": false,
        "examples": [
          {
            "id": "access.updated:key:rotated:key_01JDZ6AJ7K56PD5A8JS97ZWT3G",
            "sequence": 48211,
            "type": "access.updated",
            "time": "2026-11-13T09:30:00.000Z",
            "summary": "A secret prd key was rotated for My app (My workspace)",
            "actor": "principal:prn_01JDTQ8B2C3D4E5F6G7H8J9K0M",
            "onBehalfOf": "principal:prn_01JDSJ41R3JK54F6RKD4Y3J1GF",
            "data": {
              "kind": "key",
              "change": "rotated",
              "workspaceId": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62",
              "projectId": "prj_01JDKYC5RZKAFFK3K2ENNC1ZTK",
              "keyId": "key_01JDZ6AJ7K56PD5A8JS97ZWT3G",
              "keyType": "secret",
              "environment": "prd",
              "previousKeyId": "key_01JDZ11YP80FXYTCSE1CE31KM0"
            }
          }
        ]
      },
      "Project": {
        "description": "A project: one product, with a `dev` and a `prd` environment, each its own data.",
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "A project ID, `prj_…`"
          },
          "workspaceId": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "services": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The services it adopted, such as `identityhound`"
          },
          "status": {
            "type": "string",
            "enum": ["active", "pending", "deleted"]
          },
          "sender": {
            "description": "Where the project's email comes from. Absent until a verified domain is set",
            "type": "object",
            "properties": {
              "domain": {
                "type": "string"
              },
              "address": {
                "type": "string"
              }
            },
            "required": ["domain", "address"],
            "additionalProperties": false
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "deletedAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "workspaceId",
          "name",
          "services",
          "status",
          "createdAt"
        ],
        "additionalProperties": false,
        "examples": [
          {
            "id": "prj_01JDKYC5RZKAFFK3K2ENNC1ZTK",
            "workspaceId": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62",
            "name": "My app",
            "services": ["identityhound"],
            "status": "active",
            "createdAt": "2026-11-13T09:30:00.000Z"
          }
        ]
      },
      "Key": {
        "description": "A key as a list shows it: never a secret key’s secret.",
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "A key ID, `key_…`"
          },
          "projectId": {
            "type": "string"
          },
          "environment": {
            "type": "string",
            "enum": ["dev", "prd"],
            "description": "`dev` for development and tests, `prd` for production"
          },
          "kind": {
            "type": "string",
            "enum": ["secret", "publishable"]
          },
          "name": {
            "type": "string",
            "description": "What the key is for, such as `render`"
          },
          "prefix": {
            "type": "string",
            "description": "The key without its secret, to tell keys apart. A publishable key’s prefix is the whole key"
          },
          "key": {
            "description": "A publishable key in full, since it is public",
            "type": "string"
          },
          "allowedOrigins": {
            "description": "Where a publishable key works from in a browser. Empty only for a key that allows native apps",
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "allowNativeApps": {
            "description": "A publishable key only: `true` when a native app, which sends no `Origin`, may use it",
            "type": "boolean"
          },
          "status": {
            "type": "string",
            "enum": ["active", "grace", "expired", "revoked"],
            "description": "Only keys with an `active` or `grace` status work. After rotation, the old key has `grace` until `graceEndsAt`, then `expired`"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "revokedAt": {
            "type": "string",
            "format": "date-time"
          },
          "graceEndsAt": {
            "description": "After a rotation: when this key stops working",
            "type": "string",
            "format": "date-time"
          },
          "rotatedFrom": {
            "description": "The key this one replaced",
            "type": "string"
          },
          "replacedBy": {
            "description": "The key that replaced this one",
            "type": "string"
          }
        },
        "required": [
          "id",
          "projectId",
          "environment",
          "kind",
          "name",
          "prefix",
          "status",
          "createdAt"
        ],
        "additionalProperties": false,
        "examples": [
          {
            "id": "key_01JDZ11YP80FXYTCSE1CE31KM0",
            "projectId": "prj_01JDKYC5RZKAFFK3K2ENNC1ZTK",
            "environment": "dev",
            "kind": "secret",
            "name": "server",
            "prefix": "sk_test_4f1c9a2e7b3d",
            "status": "active",
            "createdAt": "2026-11-13T09:30:00.000Z"
          }
        ]
      },
      "WorkspaceKey": {
        "description": "A workspace key as a list shows it: never its secret. It reads every project of its workspace in its environment, within its permissions.",
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "A workspace key ID, `wkey_…`"
          },
          "workspaceId": {
            "type": "string"
          },
          "environment": {
            "type": "string",
            "enum": ["dev", "prd"],
            "description": "`dev` for development and tests, `prd` for production"
          },
          "name": {
            "type": "string",
            "description": "What the key is for, such as `analytics`"
          },
          "permissions": {
            "minItems": 1,
            "type": "array",
            "items": {
              "type": "string",
              "enum": ["events:read"]
            },
            "description": "What the key may do, fixed when it is issued. `events:read`: Reads each project's events and event types: query, lookup, one event, the live tail, and the type registry."
          },
          "prefix": {
            "type": "string",
            "description": "The key without its secret, `wk_test_…` or `wk_live_…`, to tell keys apart"
          },
          "status": {
            "type": "string",
            "enum": ["active", "grace", "expired", "revoked"],
            "description": "Only keys with an `active` or `grace` status work. After rotation, the old key has `grace` until `graceEndsAt`, or until `expiresAt` if it comes first. A key becomes `expired` at either deadline"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "expiresAt": {
            "description": "When it stops working, if it was issued to expire",
            "type": "string",
            "format": "date-time"
          },
          "lastUsedAt": {
            "description": "When it last made a request. Written at most once an hour, so it can be up to an hour behind. Absent until its first request",
            "type": "string",
            "format": "date-time"
          },
          "revokedAt": {
            "type": "string",
            "format": "date-time"
          },
          "graceEndsAt": {
            "description": "After a rotation: when this key stops working",
            "type": "string",
            "format": "date-time"
          },
          "rotatedFrom": {
            "description": "The key this one replaced",
            "type": "string"
          },
          "replacedBy": {
            "description": "The key that replaced this one",
            "type": "string"
          }
        },
        "required": [
          "id",
          "workspaceId",
          "environment",
          "name",
          "permissions",
          "prefix",
          "status",
          "createdAt"
        ],
        "additionalProperties": false,
        "examples": [
          {
            "id": "wkey_01JDZ8M3Q4R5S6T7V8W9X0Y1Z2",
            "workspaceId": "wsp_01JDGKQN2K4RF0M0Z2HBASFA62",
            "environment": "prd",
            "name": "analytics",
            "permissions": ["events:read"],
            "prefix": "wk_live_3c8e1f5a9d27",
            "status": "active",
            "createdAt": "2026-11-13T09:30:00.000Z",
            "lastUsedAt": "2026-11-13T09:30:00.000Z"
          }
        ]
      },
      "SendingDomainState": {
        "description": "A project’s sending domain, and the sender in force, which stays the old one until a new domain verifies.",
        "type": "object",
        "properties": {
          "projectId": {
            "type": "string"
          },
          "sendingDomain": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/SendingDomain"
              },
              {
                "type": "null"
              }
            ],
            "description": "`null` when the project asked for none"
          },
          "sender": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "domain": {
                    "type": "string"
                  },
                  "address": {
                    "type": "string"
                  }
                },
                "required": ["domain", "address"],
                "additionalProperties": false
              },
              {
                "type": "null"
              }
            ],
            "description": "Where the project’s email comes from now. `null` when it sends none in production"
          }
        },
        "required": ["projectId", "sendingDomain", "sender"],
        "additionalProperties": false,
        "examples": [
          {
            "projectId": "prj_01JDKYC5RZKAFFK3K2ENNC1ZTK",
            "sendingDomain": {
              "domain": "example.com",
              "address": "no-reply@example.com",
              "status": "pending",
              "waitingOn": ["DKIM is PENDING"],
              "records": [
                {
                  "type": "CNAME",
                  "name": "abc123._domainkey.example.com",
                  "value": "abc123.dkim.amazonses.com"
                },
                {
                  "type": "MX",
                  "name": "mail.example.com",
                  "value": "10 feedback-smtp.us-east-2.amazonses.com"
                },
                {
                  "type": "TXT",
                  "name": "mail.example.com",
                  "value": "v=spf1 include:amazonses.com ~all"
                }
              ],
              "recommended": [
                {
                  "type": "TXT",
                  "name": "_dmarc.example.com",
                  "value": "v=DMARC1; p=none;"
                }
              ],
              "requestedAt": "2026-11-13T09:30:00.000Z",
              "checkedAt": "2026-11-13T09:30:00.000Z",
              "nextCheckAt": "2026-11-13T09:35:00.000Z"
            },
            "sender": null
          }
        ]
      },
      "SendingDomain": {
        "description": "The domain a project asked to send email from.",
        "type": "object",
        "properties": {
          "domain": {
            "type": "string"
          },
          "address": {
            "type": "string",
            "description": "The address email comes from"
          },
          "status": {
            "type": "string",
            "enum": ["pending", "verified", "failed"]
          },
          "waitingOn": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "What Agentpost still waits on, in words. Empty unless pending"
          },
          "failure": {
            "description": "Why it failed, and what to do",
            "type": "string"
          },
          "records": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DnsRecord"
            },
            "description": "Add every one; verification waits on them all"
          },
          "recommended": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DnsRecord"
            },
            "description": "Records that help delivery but that nothing waits on, such as DMARC when the domain has none"
          },
          "requestedAt": {
            "type": "string",
            "format": "date-time"
          },
          "checkedAt": {
            "type": "string",
            "format": "date-time"
          },
          "nextCheckAt": {
            "description": "When Agentpost checks again. Set only while pending",
            "type": "string",
            "format": "date-time"
          },
          "verifiedAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "domain",
          "address",
          "status",
          "waitingOn",
          "records",
          "recommended",
          "requestedAt"
        ],
        "additionalProperties": false,
        "examples": [
          {
            "domain": "example.com",
            "address": "no-reply@example.com",
            "status": "pending",
            "waitingOn": ["DKIM is PENDING"],
            "records": [
              {
                "type": "CNAME",
                "name": "abc123._domainkey.example.com",
                "value": "abc123.dkim.amazonses.com"
              },
              {
                "type": "MX",
                "name": "mail.example.com",
                "value": "10 feedback-smtp.us-east-2.amazonses.com"
              },
              {
                "type": "TXT",
                "name": "mail.example.com",
                "value": "v=spf1 include:amazonses.com ~all"
              }
            ],
            "recommended": [
              {
                "type": "TXT",
                "name": "_dmarc.example.com",
                "value": "v=DMARC1; p=none;"
              }
            ],
            "requestedAt": "2026-11-13T09:30:00.000Z",
            "checkedAt": "2026-11-13T09:30:00.000Z",
            "nextCheckAt": "2026-11-13T09:35:00.000Z"
          }
        ]
      },
      "DnsRecord": {
        "description": "A record to add at a domain’s DNS provider.",
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "enum": ["CNAME", "MX", "TXT"]
          },
          "name": {
            "type": "string"
          },
          "value": {
            "type": "string"
          }
        },
        "required": ["type", "name", "value"],
        "additionalProperties": false,
        "examples": [
          {
            "type": "CNAME",
            "name": "abc123._domainkey.example.com",
            "value": "abc123.dkim.amazonses.com"
          }
        ]
      },
      "TestMessage": {
        "description": "A message a `dev` environment sent to a `.test` address.",
        "type": "object",
        "properties": {
          "template": {
            "type": "string",
            "description": "What the message is, such as `sign_in_code` or `invitation`"
          },
          "to": {
            "type": "string",
            "description": "Lowercased"
          },
          "data": {
            "type": "object",
            "propertyNames": {
              "type": "string"
            },
            "additionalProperties": {},
            "description": "The message's fields, such as `code` or `link`"
          },
          "at": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": ["template", "to", "data", "at"],
        "additionalProperties": false,
        "examples": [
          {
            "template": "sign_in_code",
            "to": "ada@example.test",
            "data": {
              "code": "123456"
            },
            "at": "2026-11-13T09:30:00.000Z"
          }
        ]
      },
      "UserToken": {
        "description": "A short-lived token for one signed-in principal, without the token.",
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "A user token ID, `utk_…`"
          },
          "projectId": {
            "type": "string"
          },
          "environment": {
            "type": "string",
            "enum": ["dev", "prd"],
            "description": "`dev` for development and tests, `prd` for production"
          },
          "principalRef": {
            "type": "string",
            "description": "Who it is for: an IdentityHound principal ID, or `external:<id>` for someone your own sign-in names"
          },
          "displayName": {
            "type": "string"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "projectId",
          "environment",
          "principalRef",
          "createdAt",
          "expiresAt"
        ],
        "additionalProperties": false,
        "examples": [
          {
            "id": "utk_01JD5AR85PC3S4RK1JDEXWT2Y5",
            "projectId": "prj_01JDKYC5RZKAFFK3K2ENNC1ZTK",
            "environment": "dev",
            "principalRef": "external:u_42",
            "displayName": "Ada Lovelace",
            "createdAt": "2026-11-13T09:30:00.000Z",
            "expiresAt": "2026-11-13T09:45:00.000Z"
          }
        ]
      },
      "Error": {
        "description": "The body of every error. Act on `error.code`: each code has an entry on [Agentpost errors](https://agentpost.tools/docs/errors).",
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "description": "What to act on. It never changes for a given error. Each error response lists the codes it can carry."
              },
              "message": {
                "type": "string",
                "description": "What went wrong, for humans. It may change."
              },
              "details": {
                "description": "What the code needs, when it needs more, such as `issues` for `invalid_request`."
              },
              "docs": {
                "type": "string",
                "format": "uri",
                "description": "The code’s entry on the errors page."
              }
            },
            "required": ["code", "message", "docs"]
          }
        },
        "required": ["error"]
      }
    },
    "securitySchemes": {
      "apiKey": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "agp_ak_apoa_…",
        "description": "A principal’s API key, from [signup](https://agentpost.tools/docs/platform/reference/workspaces#sign-up) or IdentityHound’s API key routes under `/v1/platform`. Its role in each workspace decides what it may do there."
      },
      "platformSession": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "agp_st_apoa_…",
        "description": "A principal’s session token, from [signing in to Agentpost](https://agentpost.tools/docs/platform/reference#signing-in-to-agentpost) with an emailed code. Its role in each workspace decides what it may do there."
      },
      "delegatedToken": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "agp_dt_apoa_…",
        "description": "A delegate’s token, with which it acts for its delegator within the permissions the delegation lists."
      },
      "secretKey": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "sk_…",
        "description": "Your project’s secret key, sent from your server."
      },
      "sessionToken": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "agp_st_…",
        "description": "The IdentityHound session token of a principal signed in to your project."
      },
      "userToken": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "ut_…",
        "description": "A user token, for whoever is signed in to your project."
      },
      "workspaceKey": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "wk_…",
        "description": "A workspace key, which reads every project of its workspace in one environment, one project per request, sent from your server."
      }
    }
  }
}
