{
  "openapi": "3.1.0",
  "info": {
    "title": "delta mandate Orchestrator API",
    "description": "API for submitting signed intents, proposing solutions, and managing templates. The Orchestrator verifies each proposal against the user's signed intent and the configured template.",
    "license": {
      "name": "delta mandate Evaluation License",
      "url": "/license"
    },
    "version": "0.4.1"
  },
  "paths": {
    "/config": {
      "get": {
        "tags": [
          "config"
        ],
        "description": "Get the runtime configuration.",
        "operationId": "config/get",
        "responses": {
          "200": {
            "description": "Runtime configuration",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RuntimeConfigResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      },
      "put": {
        "tags": [
          "config"
        ],
        "description": "Set the runtime configuration.",
        "operationId": "config/put",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateRuntimeConfigRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Runtime configuration updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RuntimeConfigResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid evidence extractor URL",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/intents": {
      "post": {
        "tags": [
          "intents"
        ],
        "description": "Submit a signed intent.\n\nThe signature is verified and the referenced template must exist before the intent is stored.",
        "operationId": "intents/submit",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BaseSignedMessage"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Intent accepted"
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/intents/{intent_id}": {
      "get": {
        "tags": [
          "intents"
        ],
        "description": "Get a stored intent by its ID.",
        "operationId": "intents/get",
        "parameters": [
          {
            "name": "intent_id",
            "in": "path",
            "description": "Intent ID",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/IntentId"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Intent found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BaseSignedMessage"
                }
              }
            }
          },
          "404": {
            "description": "Intent not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/proposals": {
      "post": {
        "tags": [
          "proposals"
        ],
        "description": "Submit a proposal for a pending intent, triggering the delta mandate pipeline.\n\nThe intent and its template must exist and the intent must not yet have a proposal. Evidence will be extracted from the proposed solution (URL) which is validated against the template and intent. Upon success, a proof is generated.",
        "operationId": "proposals/submit",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Proposal"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Proposal accepted, proving started"
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Intent already has a proposal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "Evidence extractor is not configured",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/templates": {
      "post": {
        "tags": [
          "templates"
        ],
        "description": "Compile and store a template from its source.\n\nThe compiled template is content-addressed by its SHA-256 hash, so submitting the same source twice returns the same template ID.",
        "operationId": "templates/submit",
        "requestBody": {
          "content": {
            "text/plain": {
              "schema": {
                "type": "string"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Template created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreateTemplateResponse"
                }
              }
            }
          },
          "400": {
            "description": "Compilation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/templates/{template_id}": {
      "delete": {
        "tags": [
          "templates"
        ],
        "description": "Delete a stored template by its ID.",
        "operationId": "templates/delete",
        "parameters": [
          {
            "name": "template_id",
            "in": "path",
            "description": "Template ID",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/HashDigest"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Template deleted"
          },
          "404": {
            "description": "Template not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "BaseSignedMessage": {
        "type": "object",
        "description": "A user-signed message",
        "required": [
          "payload",
          "signature"
        ],
        "properties": {
          "payload": {
            "$ref": "#/components/schemas/Intent",
            "description": "The data payload that is being signed."
          },
          "signature": {
            "$ref": "#/components/schemas/Signature",
            "description": "The signature corresponding to the above."
          }
        }
      },
      "CreateTemplateResponse": {
        "type": "object",
        "description": "Response returned when a template is successfully created.",
        "required": [
          "template_id"
        ],
        "properties": {
          "template_id": {
            "$ref": "#/components/schemas/HashDigest",
            "description": "Content-addressed ID of the stored template (base58-encoded SHA-256 of the compiled template bytes)."
          }
        }
      },
      "EcdsaPubKey": {
        "type": "string",
        "description": "ECDSA Public Key"
      },
      "EcdsaSignature": {
        "type": "string",
        "description": "ECDSA signature"
      },
      "Ed25519PubKey": {
        "type": "string",
        "description": "Base58-encoded Ed25519 public key (32 bytes)"
      },
      "Ed25519Scheme": {
        "type": "object",
        "description": "Represents an Ed25519 signature with its public signer",
        "required": [
          "pub_key",
          "signature"
        ],
        "properties": {
          "pub_key": {
            "$ref": "#/components/schemas/Ed25519PubKey",
            "description": "The [PubKey] of the signer"
          },
          "signature": {
            "$ref": "#/components/schemas/Ed25519Signature",
            "description": "The [Signature]"
          }
        }
      },
      "Ed25519Signature": {
        "type": "string",
        "description": "Base58-encoded Ed25519 signature bytes (64 bytes)"
      },
      "ErrorResponse": {
        "type": "object",
        "required": [
          "message"
        ],
        "properties": {
          "message": {
            "type": "string"
          }
        }
      },
      "HashDigest": {
        "type": "string",
        "description": "Base58-encoded SHA-256 hash digest (32 bytes)"
      },
      "InputMap": {
        "type": "object",
        "description": "Runtime input container, as defined in docs/API.md section 2.",
        "required": [
          "fields"
        ],
        "properties": {
          "fields": {
            "type": "object",
            "additionalProperties": {},
            "propertyNames": {
              "type": "string"
            }
          }
        }
      },
      "Intent": {
        "type": "object",
        "description": "A user's expression of intent: a template instantiated with concrete\nattribute values.\n\nThe intent specifies what the user wants to happen (`template_id`) and the\nconstraints on how it may be fulfilled (`attrs`). Intents are always\nsubmitted as a `SignedIntent` to prove authorship.",
        "required": [
          "id",
          "attrs",
          "template_id"
        ],
        "properties": {
          "attrs": {
            "$ref": "#/components/schemas/InputMap",
            "description": "Attribute values that parameterize the template."
          },
          "id": {
            "$ref": "#/components/schemas/IntentId",
            "description": "Unique identifier for this intent."
          },
          "template_id": {
            "$ref": "#/components/schemas/HashDigest",
            "description": "ID of the template that defines the rules for fulfilling this intent."
          }
        }
      },
      "IntentId": {
        "type": "string",
        "format": "uuid",
        "description": "Unique identifier for an intent, assigned by the caller."
      },
      "MultisigPubKey": {
        "type": "object",
        "description": "Represents the public parameters of a multisignature authotization policy.\n\nDefines the weight each key is associated with, and the minimal threshold\nabove which a subset of signers can emit a valid signature.\n\nEach [PubKey] defines a unique owner.",
        "required": [
          "signers",
          "threshold"
        ],
        "properties": {
          "signers": {
            "type": "object",
            "description": "The list of signers and their associated weight"
          },
          "threshold": {
            "$ref": "#/components/schemas/u64",
            "description": "The threshold above which a subset of the signers can emit a valid signature"
          }
        }
      },
      "MultisigScheme": {
        "type": "object",
        "description": "Multisignature scheme: a set of individual signatures collectively satisfying a threshold policy.",
        "required": [
          "signatures",
          "pub_key"
        ],
        "properties": {
          "pub_key": {
            "$ref": "#/components/schemas/MultisigPubKey",
            "description": "The multisig descriptor to be checked against"
          },
          "signatures": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Signature"
            },
            "description": "The list of signatures"
          }
        }
      },
      "PasskeyScheme": {
        "type": "object",
        "description": "Signature signed by a passkey (signer) device",
        "required": [
          "pub_key",
          "signature",
          "client_data",
          "authenticator_data"
        ],
        "properties": {
          "authenticator_data": {
            "type": "string",
            "description": "The bs58-encoded bytes of the [authenticator\ndata](https://www.w3.org/TR/webauthn-3/#authenticator-data)."
          },
          "client_data": {
            "type": "string",
            "description": "String containing the [client data] JSON.\n\nThis field is a string because JSON does not define property order, and\nwe must guarantee that the UTF8 bytes of this string are exactly the\nsame as those used by the passkey device.\n\n[client data]: https://www.w3.org/TR/webauthn-3/#dictdef-collectedclientdata"
          },
          "pub_key": {
            "$ref": "#/components/schemas/EcdsaPubKey"
          },
          "signature": {
            "$ref": "#/components/schemas/EcdsaSignature"
          }
        }
      },
      "Proposal": {
        "type": "object",
        "description": "An agent's proposed solution for a specific intent.\n\nOnce submitted, the Orchestrator fetches the URL and runs ZK proof generation to\nverify the proposal satisfies the intent's template constraints.",
        "required": [
          "intent_id",
          "url"
        ],
        "properties": {
          "intent_id": {
            "$ref": "#/components/schemas/IntentId",
            "description": "The ID of the intent this proposal targets."
          },
          "url": {
            "type": "string",
            "description": "URL pointing to the proposed solution payload that the Orchestrator will fetch\nand verify."
          }
        }
      },
      "RuntimeConfigResponse": {
        "type": "object",
        "description": "Runtime configuration",
        "required": [
          "evidence_extractor_url"
        ],
        "properties": {
          "evidence_extractor_url": {
            "type": "string",
            "description": "Base URL of the configured evidence extractor. Empty when unset."
          }
        }
      },
      "Signature": {
        "oneOf": [
          {
            "type": "object",
            "description": "Ed25519 signature",
            "required": [
              "Ed25519"
            ],
            "properties": {
              "Ed25519": {
                "$ref": "#/components/schemas/Ed25519Scheme",
                "description": "Ed25519 signature"
              }
            }
          },
          {
            "type": "object",
            "description": "Passkey signature",
            "required": [
              "Passkey"
            ],
            "properties": {
              "Passkey": {
                "$ref": "#/components/schemas/PasskeyScheme",
                "description": "Passkey signature"
              }
            }
          },
          {
            "type": "object",
            "description": "Multisig signature",
            "required": [
              "Multisig"
            ],
            "properties": {
              "Multisig": {
                "$ref": "#/components/schemas/MultisigScheme",
                "description": "Multisig signature"
              }
            }
          }
        ],
        "description": "A generic verifiable signature.\n\nEach variant contains a specific signature scheme, which itself contains all the necessary\ndata to verify the signature."
      },
      "UpdateRuntimeConfigRequest": {
        "type": "object",
        "description": "Runtime configuration update",
        "required": [
          "evidence_extractor_url"
        ],
        "properties": {
          "evidence_extractor_url": {
            "type": "string",
            "description": "Base URL of the evidence extractor service."
          }
        }
      },
      "u64": {
        "type": "integer",
        "format": "int64",
        "minimum": 0
      }
    }
  },
  "tags": [
    {
      "name": "intents",
      "description": "Submit and retrieve signed user intents.\n\nAn intent encodes what a user wants to happen, parameterized against a compiled template."
    },
    {
      "name": "proposals",
      "description": "Submit agent proposals for open intents.\n\nSubmitting a proposal triggers ZK proof generation to verify the solution satisfies the policy defined by the intent and the corresponding template."
    },
    {
      "name": "templates",
      "description": "Upload and delete compiled templates.\n\nTemplates define the rules that intents and proposals must satisfy."
    },
    {
      "name": "config",
      "description": "Operator-facing runtime configuration."
    }
  ]
}