{"openapi":"3.1.0","info":{"title":"Esure API","version":"1.0.0","description":"Bounded declarative Stellar Testnet scenario execution."},"servers":[{"url":"/"}],"paths":{"/health":{"get":{"operationId":"getHealth","responses":{"200":{"description":"Healthy"}}}},"/ready":{"get":{"operationId":"getReadiness","responses":{"200":{"description":"Ready"},"503":{"description":"Database unavailable"}}}},"/api/v1/scenarios":{"get":{"operationId":"listScenarios","responses":{"200":{"description":"Scenario catalogue"}}}},"/api/v1/scenarios/{scenarioId}":{"get":{"operationId":"getScenario","parameters":[{"name":"scenarioId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Scenario definition","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ScenarioV1"}}}},"404":{"description":"Not found"}}}},"/api/v1/scenarios/validate":{"post":{"operationId":"validateScenario","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ScenarioV1"}},"application/yaml":{"schema":{"type":"string"}},"text/yaml":{"schema":{"type":"string"}}}},"responses":{"200":{"description":"Validated scenario and content hash"},"400":{"description":"Invalid scenario"}}}},"/api/v1/scenarios/{scenarioId}/versions":{"get":{"operationId":"listScenarioVersions","parameters":[{"name":"scenarioId","in":"path","required":true,"schema":{"type":"string","pattern":"^[a-z0-9-]+$"}},{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":100,"default":20}},{"name":"cursor","in":"query","schema":{"type":"integer","minimum":1}}],"responses":{"200":{"description":"Bounded immutable version history"},"503":{"description":"Persistence not enabled or unavailable"}}}},"/api/v1/scenarios/{scenarioId}/versions/{version}":{"get":{"operationId":"getScenarioVersion","parameters":[{"name":"scenarioId","in":"path","required":true,"schema":{"type":"string","pattern":"^[a-z0-9-]+$"}},{"name":"version","in":"path","required":true,"schema":{"type":"integer","minimum":1}}],"responses":{"200":{"description":"Exact immutable scenario version","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ScenarioV1"}}}},"404":{"description":"Not found"}}}},"/api/v1/scenarios/{scenarioId}/versions/{version}/export":{"get":{"operationId":"exportScenarioVersion","parameters":[{"name":"scenarioId","in":"path","required":true,"schema":{"type":"string","pattern":"^[a-z0-9-]+$"}},{"name":"version","in":"path","required":true,"schema":{"type":"integer","minimum":1}},{"name":"format","in":"query","schema":{"type":"string","enum":["json","yaml"],"default":"json"}}],"responses":{"200":{"description":"Canonical version export","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ScenarioV1"}},"application/yaml":{"schema":{"type":"string"}}}},"404":{"description":"Not found"}}}},"/api/v1/runs":{"post":{"operationId":"startCataloguedRun","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","additionalProperties":false,"required":["scenarioId"],"properties":{"scenarioId":{"type":"string"},"inputs":{"type":"object","additionalProperties":false}}}}}},"responses":{"202":{"description":"Run accepted"}}}},"/api/v1/runs/definitions":{"post":{"operationId":"startDefinitionRun","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ScenarioV1"}},"application/yaml":{"schema":{"type":"string"}},"text/yaml":{"schema":{"type":"string"}}}},"responses":{"202":{"description":"Declarative run accepted"},"400":{"description":"Invalid scenario"}}}},"/api/v1/runs/{runId}":{"get":{"operationId":"getRun","parameters":[{"name":"runId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Run report"},"404":{"description":"Not found"}}}},"/api/v1/runs/{runId}/report":{"get":{"operationId":"downloadRunReport","parameters":[{"name":"runId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Final JSON report"},"409":{"description":"Run incomplete"}}}}},"components":{"schemas":{"ScenarioV1":{"$id":"https://esure.dev/schemas/scenario-v1.json","type":"object","additionalProperties":false,"required":["schemaVersion","id","version","name","description","network","accounts","assets","steps","assertions"],"properties":{"schemaVersion":{"const":1},"id":{"type":"string","pattern":"^[a-z][a-z0-9-]{0,63}$","maxLength":64},"version":{"type":"integer","minimum":1,"maximum":2147483647},"name":{"type":"string","minLength":1,"maxLength":120},"description":{"type":"string","minLength":1,"maxLength":500},"network":{"const":"testnet"},"accounts":{"type":"array","minItems":1,"maxItems":10,"items":{"type":"object","additionalProperties":false,"required":["id","generate","fund"],"properties":{"id":{"type":"string","pattern":"^[a-z][a-z0-9-]{0,63}$","maxLength":64},"generate":{"const":true},"fund":{"type":"boolean"}}}},"assets":{"type":"array","minItems":1,"maxItems":10,"items":{"oneOf":[{"type":"object","additionalProperties":false,"required":["id","type"],"properties":{"id":{"type":"string","pattern":"^[a-z][a-z0-9-]{0,63}$","maxLength":64},"type":{"const":"native"}}},{"type":"object","additionalProperties":false,"required":["id","type","code","issuer"],"properties":{"id":{"type":"string","pattern":"^[a-z][a-z0-9-]{0,63}$","maxLength":64},"type":{"const":"issued"},"code":{"type":"string","pattern":"^[A-Z0-9]{1,12}$","maxLength":12},"issuer":{"type":"string","pattern":"^[a-z][a-z0-9-]{0,63}$","maxLength":64}}}]}},"steps":{"type":"array","minItems":0,"maxItems":20,"items":{"oneOf":[{"type":"object","additionalProperties":false,"required":["id","type","account","asset"],"properties":{"id":{"type":"string","pattern":"^[a-z][a-z0-9-]{0,63}$","maxLength":64},"type":{"const":"changeTrust"},"account":{"type":"string","pattern":"^[a-z][a-z0-9-]{0,63}$","maxLength":64},"asset":{"type":"string","pattern":"^[a-z][a-z0-9-]{0,63}$","maxLength":64},"limit":{"type":"string","pattern":"^(?:0|[1-9][0-9]{0,11})(?:\\.[0-9]{1,7})?$","maxLength":20,"not":{"pattern":"^0(?:\\.0+)?$"}}}},{"type":"object","additionalProperties":false,"required":["id","type","from","to","asset","amount"],"properties":{"id":{"type":"string","pattern":"^[a-z][a-z0-9-]{0,63}$","maxLength":64},"type":{"const":"payment"},"from":{"type":"string","pattern":"^[a-z][a-z0-9-]{0,63}$","maxLength":64},"to":{"type":"string","pattern":"^[a-z][a-z0-9-]{0,63}$","maxLength":64},"asset":{"type":"string","pattern":"^[a-z][a-z0-9-]{0,63}$","maxLength":64},"amount":{"type":"string","pattern":"^(?:0|[1-9][0-9]{0,11})(?:\\.[0-9]{1,7})?$","maxLength":20,"not":{"pattern":"^0(?:\\.0+)?$"}}}}]}},"assertions":{"type":"array","minItems":1,"maxItems":20,"items":{"oneOf":[{"type":"object","additionalProperties":false,"required":["type","account","asset","amount"],"properties":{"type":{"const":"balanceEquals"},"account":{"type":"string","pattern":"^[a-z][a-z0-9-]{0,63}$","maxLength":64},"asset":{"type":"string","pattern":"^[a-z][a-z0-9-]{0,63}$","maxLength":64},"amount":{"type":"string","pattern":"^(?:0|[1-9][0-9]{0,11})(?:\\.[0-9]{1,7})?$","maxLength":20}}},{"type":"object","additionalProperties":false,"required":["type","account","asset","amount"],"properties":{"type":{"const":"balanceChangedBy"},"account":{"type":"string","pattern":"^[a-z][a-z0-9-]{0,63}$","maxLength":64},"asset":{"type":"string","pattern":"^[a-z][a-z0-9-]{0,63}$","maxLength":64},"amount":{"type":"string","pattern":"^-?(?:0|[1-9][0-9]{0,11})(?:\\.[0-9]{1,7})?$","maxLength":21}}},{"type":"object","additionalProperties":false,"required":["type","step"],"properties":{"type":{"enum":["stepSucceeded","transactionConfirmed"]},"step":{"type":"string","pattern":"^[a-z][a-z0-9-]{0,63}$","maxLength":64}}},{"type":"object","additionalProperties":false,"required":["type","step","transactionCode","operationCodes"],"properties":{"type":{"const":"stepFailedWith"},"step":{"type":"string","pattern":"^[a-z][a-z0-9-]{0,63}$","maxLength":64},"transactionCode":{"type":"string","pattern":"^[a-z][a-z0-9_]{0,63}$","maxLength":64},"operationCodes":{"type":"array","minItems":0,"maxItems":100,"items":{"type":"string","pattern":"^[a-z][a-z0-9_]{0,63}$","maxLength":64}}}},{"type":"object","additionalProperties":false,"required":["type","account","asset"],"properties":{"type":{"enum":["trustlineExists","trustlineMissing"]},"account":{"type":"string","pattern":"^[a-z][a-z0-9-]{0,63}$","maxLength":64},"asset":{"type":"string","pattern":"^[a-z][a-z0-9-]{0,63}$","maxLength":64}}},{"type":"object","additionalProperties":false,"required":["type","account"],"properties":{"type":{"const":"accountExists"},"account":{"type":"string","pattern":"^[a-z][a-z0-9-]{0,63}$","maxLength":64}}}]}}}},"CataloguedRunRequest":{"type":"object","additionalProperties":false,"required":["scenarioId"],"properties":{"scenarioId":{"type":"string"},"inputs":{"type":"object","additionalProperties":false}}}}}}