{
  "openapi": "3.1.0",
  "info": {
    "title": "AgentDB JSON-LD Action API",
    "version": "0.1.0",
    "description": "The complete public surface: two endpoints accepting Schema.org JSON-LD action documents. POST /action is the data plane (tenant entity CRUD, search, analytics); POST /action/admin is the admin plane (provisioning, membership, pairing/token rotation, and the public auth actions). The URL selects the plane — no property of the body does. This document is authored from the canonical AgentDB contract (TD-7) and summarizes response shapes; it will be replaced by a server-generated contract when one exists. The JSON-LD embedded across this site declares the same targets this document defines."
  },
  "servers": [
    {
      "url": "https://staging-api.agentdb.com/api",
      "description": "AgentDB API root (set per deployment)"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/action": {
      "post": {
        "operationId": "postDataAction",
        "summary": "Data plane — Schema.org entity actions",
        "description": "Wrap any Schema.org entity in an action document: CreateAction (upserts on identifier), UpdateAction, DeleteAction, FindAction, SearchAction, AddAction, AppendAction, PrependAction, and AssessAction flavors (analytics, intent classification, vocabulary tuning). Realtime verbs (SubscribeAction, ListenAction, ScheduleAction) ride this endpoint too. Do not send top-level location/VirtualLocation (400). Optionally add an `apikey` header to target a workspace app.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ActionDocument"
              },
              "examples": {
                "create-first-entity": {
                  "summary": "CreateAction — create-first-entity (CI-executed fixture)",
                  "value": {
                    "@context": "https://schema.org/",
                    "@type": "CreateAction",
                    "object": {
                      "@type": "Product",
                      "identifier": "site-fixture:first-entity",
                      "name": "My first entity",
                      "description": "Created by the AgentDB quickstart acceptance sequence."
                    }
                  }
                },
                "search-first-entity": {
                  "summary": "SearchAction — search-first-entity (CI-executed fixture)",
                  "value": {
                    "@context": "https://schema.org/",
                    "@type": "SearchAction",
                    "query": "first entity",
                    "object": {
                      "@type": "Product"
                    }
                  }
                },
                "find-first-entity": {
                  "summary": "FindAction — find-first-entity (CI-executed fixture)",
                  "value": {
                    "@context": "https://schema.org/",
                    "@type": "FindAction",
                    "identifier": "site-fixture:first-entity"
                  }
                },
                "publish-vocab-pack": {
                  "summary": "CreateAction — publish-vocab-pack (CI-executed fixture)",
                  "value": {
                    "@context": "https://schema.org/",
                    "@type": "CreateAction",
                    "object": {
                      "@type": "DefinedTermSet",
                      "additionalType": "VocabPack",
                      "identifier": "site-fixture:vocab-pack:tasks:1.0.0",
                      "name": "Tasks vocab",
                      "version": "1.0.0",
                      "hasDefinedTerm": [
                        {
                          "@type": "DefinedTerm",
                          "name": "wip",
                          "termCode": "In Progress",
                          "alternateName": [
                            "active",
                            "working"
                          ]
                        },
                        {
                          "@type": "DefinedTerm",
                          "name": "done",
                          "termCode": "Completed",
                          "alternateName": [
                            "finished",
                            "shipped"
                          ]
                        }
                      ]
                    }
                  }
                },
                "classify-intent": {
                  "summary": "AssessAction — classify-intent (CI-executed fixture)",
                  "value": {
                    "@context": "https://schema.org/",
                    "@type": "AssessAction",
                    "additionalType": "ClassifyIntent",
                    "object": {
                      "@type": "Question",
                      "text": "show me everything that's still in progress"
                    }
                  }
                },
                "learn-intent": {
                  "summary": "AssessAction — learn-intent (CI-executed fixture)",
                  "value": {
                    "@context": "https://schema.org/",
                    "@type": "AssessAction",
                    "additionalType": "LearnIntent",
                    "object": {
                      "@type": "Question",
                      "text": "site-fixture: hand this off to"
                    },
                    "instrument": [
                      {
                        "@type": "PropertyValue",
                        "name": "canonicalCommand",
                        "value": "reassign"
                      },
                      {
                        "@type": "PropertyValue",
                        "name": "resolvedAction",
                        "value": "update"
                      },
                      {
                        "@type": "PropertyValue",
                        "name": "resolvedEntity",
                        "value": "Task"
                      }
                    ]
                  }
                },
                "create-order": {
                  "summary": "CreateAction — create-order (CI-executed fixture)",
                  "value": {
                    "@context": "https://schema.org/",
                    "@type": "CreateAction",
                    "object": {
                      "@type": "Order",
                      "identifier": "site-fixture:order-1",
                      "orderedItem": {
                        "@type": "Product",
                        "identifier": "site-fixture:coffee-ethiopia",
                        "name": "Ethiopia Yirgacheffe, 250g"
                      },
                      "customer": {
                        "@type": "Person",
                        "identifier": "site-fixture:customer-1",
                        "name": "Visiting Agent's Human"
                      }
                    }
                  }
                },
                "find-order": {
                  "summary": "FindAction — find-order (CI-executed fixture)",
                  "value": {
                    "@context": "https://schema.org/",
                    "@type": "FindAction",
                    "identifier": "site-fixture:order-1"
                  }
                }
              }
            },
            "application/ld+json": {
              "schema": {
                "$ref": "#/components/schemas/ActionDocument"
              },
              "examples": {
                "create-first-entity": {
                  "summary": "CreateAction — create-first-entity (CI-executed fixture)",
                  "value": {
                    "@context": "https://schema.org/",
                    "@type": "CreateAction",
                    "object": {
                      "@type": "Product",
                      "identifier": "site-fixture:first-entity",
                      "name": "My first entity",
                      "description": "Created by the AgentDB quickstart acceptance sequence."
                    }
                  }
                },
                "search-first-entity": {
                  "summary": "SearchAction — search-first-entity (CI-executed fixture)",
                  "value": {
                    "@context": "https://schema.org/",
                    "@type": "SearchAction",
                    "query": "first entity",
                    "object": {
                      "@type": "Product"
                    }
                  }
                },
                "find-first-entity": {
                  "summary": "FindAction — find-first-entity (CI-executed fixture)",
                  "value": {
                    "@context": "https://schema.org/",
                    "@type": "FindAction",
                    "identifier": "site-fixture:first-entity"
                  }
                },
                "publish-vocab-pack": {
                  "summary": "CreateAction — publish-vocab-pack (CI-executed fixture)",
                  "value": {
                    "@context": "https://schema.org/",
                    "@type": "CreateAction",
                    "object": {
                      "@type": "DefinedTermSet",
                      "additionalType": "VocabPack",
                      "identifier": "site-fixture:vocab-pack:tasks:1.0.0",
                      "name": "Tasks vocab",
                      "version": "1.0.0",
                      "hasDefinedTerm": [
                        {
                          "@type": "DefinedTerm",
                          "name": "wip",
                          "termCode": "In Progress",
                          "alternateName": [
                            "active",
                            "working"
                          ]
                        },
                        {
                          "@type": "DefinedTerm",
                          "name": "done",
                          "termCode": "Completed",
                          "alternateName": [
                            "finished",
                            "shipped"
                          ]
                        }
                      ]
                    }
                  }
                },
                "classify-intent": {
                  "summary": "AssessAction — classify-intent (CI-executed fixture)",
                  "value": {
                    "@context": "https://schema.org/",
                    "@type": "AssessAction",
                    "additionalType": "ClassifyIntent",
                    "object": {
                      "@type": "Question",
                      "text": "show me everything that's still in progress"
                    }
                  }
                },
                "learn-intent": {
                  "summary": "AssessAction — learn-intent (CI-executed fixture)",
                  "value": {
                    "@context": "https://schema.org/",
                    "@type": "AssessAction",
                    "additionalType": "LearnIntent",
                    "object": {
                      "@type": "Question",
                      "text": "site-fixture: hand this off to"
                    },
                    "instrument": [
                      {
                        "@type": "PropertyValue",
                        "name": "canonicalCommand",
                        "value": "reassign"
                      },
                      {
                        "@type": "PropertyValue",
                        "name": "resolvedAction",
                        "value": "update"
                      },
                      {
                        "@type": "PropertyValue",
                        "name": "resolvedEntity",
                        "value": "Task"
                      }
                    ]
                  }
                },
                "create-order": {
                  "summary": "CreateAction — create-order (CI-executed fixture)",
                  "value": {
                    "@context": "https://schema.org/",
                    "@type": "CreateAction",
                    "object": {
                      "@type": "Order",
                      "identifier": "site-fixture:order-1",
                      "orderedItem": {
                        "@type": "Product",
                        "identifier": "site-fixture:coffee-ethiopia",
                        "name": "Ethiopia Yirgacheffe, 250g"
                      },
                      "customer": {
                        "@type": "Person",
                        "identifier": "site-fixture:customer-1",
                        "name": "Visiting Agent's Human"
                      }
                    }
                  }
                },
                "find-order": {
                  "summary": "FindAction — find-order (CI-executed fixture)",
                  "value": {
                    "@context": "https://schema.org/",
                    "@type": "FindAction",
                    "identifier": "site-fixture:order-1"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Wrapped result: extract the entity (or action node with `result`) from `data.jsonToQueryBuilder`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DataResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "description": "Plan limit exceeded — the JSON-LD error names the limit; surface it to a human rather than retrying."
          }
        }
      }
    },
    "/action/admin": {
      "post": {
        "operationId": "postAdminAction",
        "summary": "Admin plane — provisioning, membership, pairing, public auth",
        "description": "Admin operations (organizations, agents, services, teams, workspaces, API keys, DiscoverAction, membership, billing) plus the unauthenticated public actions: agent pairing and token rotation (RegisterAction + SoftwareApplication with a pairingToken/refreshToken PropertyValue instrument) and the email one-time-passcode flow (LoginAction with Person email, then the same plus a `code` instrument).",
        "security": [
          {
            "bearerAuth": []
          },
          {}
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ActionDocument"
              }
            },
            "application/ld+json": {
              "schema": {
                "$ref": "#/components/schemas/ActionDocument"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "A JSON-LD action document with actionStatus and a result node (for pairing/login: a DigitalDocument whose `text` is the JWT).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ActionDocument"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "description": "Obtained by pairing (RegisterAction with a pairingToken instrument) or email OTP login — both on POST /action/admin with no auth header."
      }
    },
    "schemas": {
      "ActionDocument": {
        "type": "object",
        "description": "A Schema.org JSON-LD action document. @type is the verb; entity payloads ride on `object` (or `query` for SearchAction). Properties must be valid Schema.org properties for their type.",
        "required": [
          "@context",
          "@type"
        ],
        "properties": {
          "@context": {
            "type": "string",
            "examples": [
              "https://schema.org/"
            ]
          },
          "@type": {
            "type": "string",
            "description": "The action verb",
            "examples": [
              "CreateAction",
              "UpdateAction",
              "DeleteAction",
              "FindAction",
              "SearchAction",
              "AddAction",
              "AppendAction",
              "PrependAction",
              "AssessAction",
              "RegisterAction",
              "LoginAction",
              "SubscribeAction",
              "ListenAction",
              "ScheduleAction",
              "DiscoverAction"
            ]
          },
          "object": {
            "type": "object",
            "description": "The Schema.org entity the action operates on"
          },
          "query": {
            "type": "string",
            "description": "SearchAction free-text query"
          },
          "identifier": {
            "type": "string",
            "description": "Target key for FindAction (plain or urn:-prefixed)"
          },
          "instrument": {
            "description": "PropertyValue credential/parameter carriers (pairingToken, refreshToken, code, …)"
          },
          "additionalType": {
            "type": "string",
            "description": "AssessAction flavor (Analyze, ClassifyIntent, LearnIntent, …)"
          }
        },
        "additionalProperties": true
      },
      "DataResponse": {
        "type": "object",
        "description": "Every data-plane response wraps its payload in data.jsonToQueryBuilder. For SearchAction the value is a SearchAction node whose `result` is the entity array.",
        "required": [
          "data"
        ],
        "properties": {
          "data": {
            "type": "object",
            "required": [
              "jsonToQueryBuilder"
            ],
            "properties": {
              "jsonToQueryBuilder": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        }
      },
      "ErrorResponse": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string",
            "description": "Human-readable message, e.g. \"Data service errors: Entity not found by identifier: …\""
          }
        }
      }
    },
    "responses": {
      "BadRequest": {
        "description": "Invalid payload — schema violation, top-level location, legacy admin marker, or IRI @id conflict semantics surfaced as an error body.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      },
      "Unauthorized": {
        "description": "Missing or expired JWT — rotate via RegisterAction with a refreshToken instrument."
      }
    }
  }
}