{"openapi":"3.1.0","info":{"title":"Praecise Shield","version":"0.1.0","description":"Early and unproven. A touch is not proof of a human. An agent driving a real browser passes as a person. No edge rules, no certificates."},"servers":[{"url":"https://shield.praecise.com"}],"tags":[{"name":"Sites","description":"Made by a Praecise product with the admin key (the Praecise Cloud console does it for a project)."},{"name":"Your server","description":"Called by the site's own server, with its secret."},{"name":"Report","description":"Counts and plain sentences, with the site secret."},{"name":"Agents as customers","description":"Rules per declared agent, and who answers for an agent."}],"components":{"securitySchemes":{"manage":{"type":"http","scheme":"bearer","description":"The agent's manage secret (psm_…), shown once when the agent proves control of its name."},"admin":{"type":"http","scheme":"bearer","description":"The admin key, held by a Praecise product."},"siteSecret":{"type":"http","scheme":"bearer","description":"The site secret (pss_…), shown once."}}},"paths":{"/sites":{"post":{"operationId":"sites-create","tags":["Sites"],"summary":"Add a site","security":[{"admin":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","description":""},"origins":{"type":"array","minItems":1,"maxItems":20,"items":{"type":"string","format":"uri"},"description":"One to twenty https origins, no path."},"owner":{"type":"string","description":"The project or organisation id."},"praeciseAccount":{"type":"string","description":"The Praecise account the usage bills to."},"relationship":{"type":"string","description":"Its billing relationship, if known."}},"required":["name","origins","owner"]}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"type":"object","properties":{"site":{"type":"string","description":""},"secret":{"type":"string","description":"Shown this once."},"origins":{"type":"array","minItems":1,"maxItems":20,"items":{"type":"string","format":"uri"},"description":"One to twenty https origins, no path."},"name":{"type":"string","description":""}},"required":[]}}}}}},"get":{"operationId":"sites-list","tags":["Sites"],"summary":"List the sites of an owner","security":[{"admin":[]}],"parameters":[{"name":"owner","in":"query","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"object","properties":{"sites":{"type":"array","items":{"type":"object","properties":{"site":{"type":"string","description":""},"name":{"type":"string","description":""},"owner":{"type":"string","description":""},"origins":{"type":"array","minItems":1,"maxItems":20,"items":{"type":"string","format":"uri"},"description":"One to twenty https origins, no path."},"createdAt":{"type":"string","description":""}},"required":[]}}},"required":[]}}}}}}},"/sites/{site}":{"get":{"operationId":"sites-read","tags":["Sites"],"summary":"Read a site and its last seven days","security":[{"admin":[]}],"parameters":[{"name":"site","in":"path","required":true,"schema":{"type":"string"},"description":"The site key (ps_…)."}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"object","properties":{"site":{"type":"string","description":""},"name":{"type":"string","description":""},"owner":{"type":"string","description":""},"origins":{"type":"array","minItems":1,"maxItems":20,"items":{"type":"string","format":"uri"},"description":"One to twenty https origins, no path."},"today":{"type":"object"},"from":{"type":"string","description":""},"to":{"type":"string","description":""},"totals":{"type":"object"},"lines":{"type":"array","items":{"type":"string"}},"toDo":{"type":"array","items":{"type":"string"}}},"required":[]}}}}}},"put":{"operationId":"sites-update","tags":["Sites"],"summary":"Change the origins","security":[{"admin":[]}],"parameters":[{"name":"site","in":"path","required":true,"schema":{"type":"string"},"description":"The site key (ps_…)."}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"origins":{"type":"array","minItems":1,"maxItems":20,"items":{"type":"string","format":"uri"},"description":"One to twenty https origins, no path."},"name":{"type":"string","description":""}},"required":["origins"]}}}},"responses":{"200":{"description":"Changed"}}},"post":{"operationId":"sites-rotate","tags":["Sites"],"summary":"Rotate the secret, or link the site to a Praecise account (praeciseAccount, relationship)","security":[{"admin":[]}],"parameters":[{"name":"site","in":"path","required":true,"schema":{"type":"string"},"description":"The site key (ps_…)."}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"rotate":{"type":"boolean","const":true},"praeciseAccount":{"type":"string","description":"The Praecise account the usage bills to."},"relationship":{"type":"string","description":"Its billing relationship, if known."}},"required":[]}}}},"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"object","properties":{"secret":{"type":"string","description":"The new secret, shown this once (a rotate)."},"praeciseAccount":{"type":"string","description":""}},"required":[]}}}}}},"delete":{"operationId":"sites-delete","tags":["Sites"],"summary":"Remove a site","security":[{"admin":[]}],"parameters":[{"name":"site","in":"path","required":true,"schema":{"type":"string"},"description":"The site key (ps_…)."}],"responses":{"200":{"description":"Removed"}}}},"/verify":{"post":{"operationId":"verify","tags":["Your server"],"summary":"Confirm a token from a page","description":"A token answers yes once and lasts two minutes.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"site":{"type":"string","description":""},"secret":{"type":"string","description":""},"token":{"type":"string","description":""},"action":{"type":"string","description":""}},"required":["site","secret","token"]}}}},"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"},"class":{"type":"string","description":"person when ok."},"score":{"type":"number"},"action":{"type":"string","description":""},"presence":{"type":"string","description":""},"reason":{"type":"string","description":"When not ok."}},"required":["ok"]}}}}}}},"/verify-agent":{"post":{"operationId":"verify-agent","tags":["Your server"],"summary":"Check a signed agent request","description":"Not yet met by a real agent.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"site":{"type":"string","description":""},"secret":{"type":"string","description":""},"method":{"type":"string","description":""},"authority":{"type":"string","description":""},"path":{"type":"string","description":""},"headers":{"type":"object","properties":{"signature":{"type":"string","description":""},"signature-input":{"type":"string","description":""},"signature-agent":{"type":"string","description":""}},"required":[]},"intent":{"type":"string","enum":["read","act"],"description":"What the request is. Default from the method: GET and HEAD read, the rest act."}},"required":["site","secret","method","authority","path","headers"]}}}},"responses":{"200":{"description":"decision and accountable only with ok: an undeclared caller gets no decision.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"},"class":{"type":"string","description":"declared_agent or undeclared."},"agent":{"type":"string","description":""},"keyid":{"type":"string","description":""},"decision":{"type":"object","properties":{"allowed":{"type":"boolean"},"rule":{"type":"string","enum":["welcome","read_only","ceiling","refuse","default"]},"reason":{"type":"string","description":""}},"required":["allowed","rule","reason"]},"accountable":{"oneOf":[{"type":"object","properties":{"kind":{"type":"string","enum":["praecise_account","network_identity","organisation"]},"id":{"type":"string","description":""},"verified":{"type":"boolean"},"since":{"type":"string","description":""},"contact":{"type":"string","description":"organisation only."},"note":{"type":"string","description":"Why it is not verified."}},"required":["kind","id","verified","since"]},{"type":"null"}],"description":"Who answers for the agent; null when none is stated or the agent never proved its name."},"reason":{"type":"string","description":"When not ok."}},"required":["ok"]}}}}}}},"/agents":{"get":{"operationId":"agents-rules-read","tags":["Agents as customers"],"summary":"Read the site's rules for declared agents","security":[{"siteSecret":[]}],"parameters":[{"name":"site","in":"query","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"object","properties":{"site":{"type":"string","description":""},"default":{"type":"string","enum":["welcome","read_only","refuse","accountable_only"],"description":"For a declared agent no rule names. read_only unless set."},"agents":{"type":"object","additionalProperties":{"type":"object","properties":{"mode":{"type":"string","enum":["welcome","read_only","ceiling","refuse"]},"perMinute":{"type":"integer","minimum":1,"maximum":100000,"description":"Only with mode ceiling."},"note":{"type":"string","maxLength":200}},"required":["mode"]},"description":"Keyed by the agent's name: the host of its key directory. Up to 200."}},"required":[]}}}}}},"put":{"operationId":"agents-rules-set","tags":["Agents as customers"],"summary":"Set the site's rules for declared agents","description":"A field sent replaces that field whole; one left out is kept.","security":[{"siteSecret":[]}],"parameters":[{"name":"site","in":"query","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"default":{"type":"string","enum":["welcome","read_only","refuse","accountable_only"],"description":"For a declared agent no rule names. read_only unless set."},"agents":{"type":"object","additionalProperties":{"type":"object","properties":{"mode":{"type":"string","enum":["welcome","read_only","ceiling","refuse"]},"perMinute":{"type":"integer","minimum":1,"maximum":100000,"description":"Only with mode ceiling."},"note":{"type":"string","maxLength":200}},"required":["mode"]},"description":"Keyed by the agent's name: the host of its key directory. Up to 200."}},"required":[]}}}},"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"object","properties":{"site":{"type":"string","description":""},"default":{"type":"string","enum":["welcome","read_only","refuse","accountable_only"],"description":"For a declared agent no rule names. read_only unless set."},"agents":{"type":"object","additionalProperties":{"type":"object","properties":{"mode":{"type":"string","enum":["welcome","read_only","ceiling","refuse"]},"perMinute":{"type":"integer","minimum":1,"maximum":100000,"description":"Only with mode ceiling."},"note":{"type":"string","maxLength":200}},"required":["mode"]},"description":"Keyed by the agent's name: the host of its key directory. Up to 200."}},"required":[]}}}}}}},"/sites/{site}/agents":{"get":{"operationId":"sites-agents-read","tags":["Agents as customers"],"summary":"Read a site's rules for declared agents","security":[{"admin":[]}],"parameters":[{"name":"site","in":"path","required":true,"schema":{"type":"string"},"description":"The site key (ps_…)."}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"object","properties":{"site":{"type":"string","description":""},"default":{"type":"string","enum":["welcome","read_only","refuse","accountable_only"],"description":"For a declared agent no rule names. read_only unless set."},"agents":{"type":"object","additionalProperties":{"type":"object","properties":{"mode":{"type":"string","enum":["welcome","read_only","ceiling","refuse"]},"perMinute":{"type":"integer","minimum":1,"maximum":100000,"description":"Only with mode ceiling."},"note":{"type":"string","maxLength":200}},"required":["mode"]},"description":"Keyed by the agent's name: the host of its key directory. Up to 200."}},"required":[]}}}}}},"put":{"operationId":"sites-agents-set","tags":["Agents as customers"],"summary":"Set a site's rules for declared agents","security":[{"admin":[]}],"parameters":[{"name":"site","in":"path","required":true,"schema":{"type":"string"},"description":"The site key (ps_…)."}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"default":{"type":"string","enum":["welcome","read_only","refuse","accountable_only"],"description":"For a declared agent no rule names. read_only unless set."},"agents":{"type":"object","additionalProperties":{"type":"object","properties":{"mode":{"type":"string","enum":["welcome","read_only","ceiling","refuse"]},"perMinute":{"type":"integer","minimum":1,"maximum":100000,"description":"Only with mode ceiling."},"note":{"type":"string","maxLength":200}},"required":["mode"]},"description":"Keyed by the agent's name: the host of its key directory. Up to 200."}},"required":[]}}}},"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"object","properties":{"site":{"type":"string","description":""},"default":{"type":"string","enum":["welcome","read_only","refuse","accountable_only"],"description":"For a declared agent no rule names. read_only unless set."},"agents":{"type":"object","additionalProperties":{"type":"object","properties":{"mode":{"type":"string","enum":["welcome","read_only","ceiling","refuse"]},"perMinute":{"type":"integer","minimum":1,"maximum":100000,"description":"Only with mode ceiling."},"note":{"type":"string","maxLength":200}},"required":["mode"]},"description":"Keyed by the agent's name: the host of its key directory. Up to 200."}},"required":[]}}}}}}},"/agent-owners":{"post":{"operationId":"agent-owners-claim","tags":["Agents as customers"],"summary":"Claim an agent's name","description":"Gives a token to publish at https://<host>/.well-known/praecise-agent.json as { \"token\": \"...\" }. For a name already proven, gives a pendingToken to prove control again.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"agent":{"type":"string","description":"The host of the agent's key directory."}},"required":["agent"]}}}},"responses":{"200":{"description":"Already claimed: the token again, or a pendingToken for a proven name."},"201":{"description":"Claimed","content":{"application/json":{"schema":{"type":"object","properties":{"agent":{"type":"string","description":""},"status":{"type":"string","description":""},"token":{"type":"string","description":""},"publishAt":{"type":"string","description":""},"publish":{"type":"object","properties":{"token":{"type":"string","description":""}},"required":[]}},"required":[]}}}}}}},"/agent-owners/prove":{"post":{"operationId":"agent-owners-prove","tags":["Agents as customers"],"summary":"Prove control of the name","description":"Shield reads the file (https only, public host, no redirect, size and time limited). Once in ten seconds per agent.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"agent":{"type":"string","description":""}},"required":["agent"]}}}},"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"object","properties":{"agent":{"type":"string","description":""},"proven":{"type":"boolean"},"manageSecret":{"type":"string","description":"Shown once, only when proven. Replaces any earlier one and clears a stated owner when this proves a new token."},"reason":{"type":"string","description":""}},"required":["proven"]}}}}}}},"/agent-owners/{agent}":{"get":{"operationId":"agent-owners-read","tags":["Agents as customers"],"summary":"Read an agent's record","security":[{"manage":[]},{"admin":[]}],"parameters":[{"name":"agent","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"object","properties":{"agent":{"type":"string","description":""},"status":{"type":"string","description":""},"claimedAt":{"type":"string","description":""},"provenAt":{"type":"string","description":""},"accountable":{"oneOf":[{"type":"object","properties":{"kind":{"type":"string","enum":["praecise_account","network_identity","organisation"]},"id":{"type":"string","description":""},"verified":{"type":"boolean"},"since":{"type":"string","description":""},"contact":{"type":"string","description":"organisation only."},"note":{"type":"string","description":"Why it is not verified."}},"required":["kind","id","verified","since"]},{"type":"null"}]}},"required":[]}}}}}},"put":{"operationId":"agent-owners-set","tags":["Agents as customers"],"summary":"State who answers for the agent","description":"praecise_account needs the admin key; the other kinds need the manage secret (the admin key is also taken). The agent must have proven its name.","security":[{"manage":[]},{"admin":[]}],"parameters":[{"name":"agent","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"owner":{"oneOf":[{"type":"object","properties":{"kind":{"const":"organisation"},"name":{"type":"string","description":"Legal name."},"contact":{"type":"string","description":"Contact email address."}},"required":["kind","name","contact"]},{"type":"object","properties":{"kind":{"const":"network_identity"},"address":{"type":"string","description":"0x… address (checked) or another form (kept as claimed, not verified)."},"proof":{"type":"string","description":"0x… signature over: praecise-shield agent <host> owner <address> <token>"}},"required":["kind","address"]},{"type":"object","properties":{"kind":{"const":"praecise_account"},"id":{"type":"string","description":""}},"required":["kind","id"]}]}},"required":["owner"]}}}},"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"object","properties":{"agent":{"type":"string","description":""},"accountable":{"type":"object","properties":{"kind":{"type":"string","enum":["praecise_account","network_identity","organisation"]},"id":{"type":"string","description":""},"verified":{"type":"boolean"},"since":{"type":"string","description":""},"contact":{"type":"string","description":"organisation only."},"note":{"type":"string","description":"Why it is not verified."}},"required":["kind","id","verified","since"]}},"required":[]}}}},"400":{"description":"The proof did not match."},"409":{"description":"The agent has not proven its name."}}},"delete":{"operationId":"agent-owners-clear","tags":["Agents as customers"],"summary":"Remove the stated owner","security":[{"manage":[]},{"admin":[]}],"parameters":[{"name":"agent","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Removed"}}}},"/counts":{"get":{"operationId":"counts","tags":["Report"],"summary":"Counts per UTC day","security":[{"siteSecret":[]}],"parameters":[{"name":"site","in":"query","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"challenges, people, people_by_touch, below_the_line, failed, verified, refused, declared_agents, unsigned_or_bad_agents"}}}},"/report":{"get":{"operationId":"report","tags":["Report"],"summary":"The last seven days in plain sentences","security":[{"siteSecret":[]}],"parameters":[{"name":"site","in":"query","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Totals, lines, what to do and the agents seen.","content":{"application/json":{"schema":{"type":"object","properties":{"totals":{"type":"object"},"lines":{"type":"array","items":{"type":"string"}},"toDo":{"type":"array","items":{"type":"string"}},"agents":{"type":"array","description":"Each declared agent seen in the period.","items":{"type":"object","properties":{"agent":{"type":"string","description":""},"requests":{"type":"integer"},"allowed":{"type":"integer"},"refused":{"type":"integer"},"rule":{"type":"string","description":""},"sentence":{"type":"string","description":""}},"required":[]}}},"required":[]}}}}}}}}}