{"openapi":"3.1.0","info":{"title":"Snippets API","version":"1.0.0","description":"Create, read, update, and delete code or text snippets. Save the edit token returned when you create a snippet. It is required to update or delete that snippet."},"servers":[{"url":"https://snippets.ix0.io"}],"paths":{"/health":{"get":{"summary":"Check service health","responses":{"200":{"description":"Service is available","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string","const":"ok"}},"required":["status"]}}}}}}},"/snippets":{"post":{"summary":"Create a snippet","description":"Store the edit_token from the response. The service never returns it again.","parameters":[{"$ref":"#/components/parameters/Origin"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateSnippet"}}}},"responses":{"201":{"description":"Snippet created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateResponse"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"403":{"$ref":"#/components/responses/CsrfError"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/snippets/{id}":{"put":{"summary":"Update a snippet","parameters":[{"$ref":"#/components/parameters/SnippetId"},{"$ref":"#/components/parameters/Origin"},{"$ref":"#/components/parameters/EditToken"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateSnippet"}}}},"responses":{"200":{"description":"Snippet updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LocationResponse"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"403":{"$ref":"#/components/responses/EditTokenError"},"404":{"$ref":"#/components/responses/NotFound"}}},"delete":{"summary":"Delete a snippet","parameters":[{"$ref":"#/components/parameters/SnippetId"},{"$ref":"#/components/parameters/Origin"},{"$ref":"#/components/parameters/EditToken"}],"responses":{"200":{"description":"Snippet deleted","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","const":true}},"required":["success"]}}}},"403":{"$ref":"#/components/responses/EditTokenError"},"404":{"$ref":"#/components/responses/NotFound"}}}},"/s/{id}":{"get":{"summary":"Read a snippet","description":"Set Accept to application/json for a JSON response. A public custom alias can be used in place of the ID.","parameters":[{"$ref":"#/components/parameters/SnippetId"}],"responses":{"200":{"description":"Snippet","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Snippet"}}}},"401":{"description":"Password required"},"404":{"$ref":"#/components/responses/NotFound"}}}},"/raw/{id}":{"get":{"summary":"Read snippet content as plain text","parameters":[{"$ref":"#/components/parameters/SnippetId"}],"responses":{"200":{"description":"Snippet content","content":{"text/plain":{"schema":{"type":"string"}}}},"404":{"$ref":"#/components/responses/NotFound"}}}}},"components":{"parameters":{"SnippetId":{"name":"id","in":"path","required":true,"schema":{"type":"string","minLength":3,"maxLength":50},"description":"Snippet ID or a public custom alias for read operations."},"Origin":{"name":"Origin","in":"header","required":true,"schema":{"type":"string","format":"uri"},"description":"The origin of the configured public URL, without a path. Required for all write requests."},"EditToken":{"name":"X-Edit-Token","in":"header","required":true,"schema":{"type":"string"},"description":"The edit token returned when the snippet was created."}},"schemas":{"CreateSnippet":{"type":"object","required":["content"],"properties":{"title":{"type":"string","maxLength":200,"default":"Untitled snippet"},"language":{"type":"string","maxLength":50,"default":"text"},"content":{"type":"string","minLength":1,"maxLength":1048576},"tags":{"oneOf":[{"type":"array","items":{"type":"string","pattern":"^[a-z0-9-]+$"},"maxItems":10},{"type":"string"}]},"expiration":{"type":"string","enum":["10m","1h","1d","1w","1m"]},"burn_after_reading":{"type":"boolean"},"description":{"type":"string","maxLength":1000},"custom_url":{"type":"string","pattern":"^[a-z0-9]([a-z0-9-]*[a-z0-9])?$","minLength":3,"maxLength":50},"password":{"type":"string","minLength":8,"maxLength":72}}},"UpdateSnippet":{"type":"object","properties":{"title":{"type":"string","maxLength":200,"description":"Omit to keep the current title. An empty value resets it to Untitled snippet."},"language":{"type":"string","maxLength":50,"description":"Omit to keep the current language. An empty value resets it to text."},"content":{"type":"string","minLength":1,"maxLength":1048576},"tags":{"oneOf":[{"type":"array","items":{"type":"string","pattern":"^[a-z0-9-]+$"},"maxItems":10},{"type":"string"}]},"expiration":{"oneOf":[{"type":"string","enum":["10m","1h","1d","1w","1m"]},{"type":"null"}]},"burn_after_reading":{"type":"boolean"},"description":{"type":"string","maxLength":1000}}},"CreateResponse":{"type":"object","required":["id","url","edit_token"],"properties":{"id":{"type":"string"},"url":{"type":"string"},"edit_token":{"type":"string"}}},"LocationResponse":{"type":"object","required":["id","url"],"properties":{"id":{"type":"string"},"url":{"type":"string"}}},"Snippet":{"type":"object","required":["id","title","language","content","tags","created_at"],"properties":{"id":{"type":"string"},"title":{"type":"string"},"language":{"type":"string"},"content":{"type":"string"},"tags":{"type":"array","items":{"type":"string"}},"created_at":{"type":"string","format":"date-time"},"expires_at":{"type":"string","format":"date-time"},"burn_after_reading":{"type":"boolean"},"description":{"type":"string"},"custom_url":{"type":"string"}}},"Error":{"type":"object","required":["error"],"properties":{"error":{"type":"string"}}}},"responses":{"BadRequest":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"CsrfError":{"description":"Origin header is missing or does not match the public URL","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"EditTokenError":{"description":"Origin or edit token is invalid","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"NotFound":{"description":"Snippet not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"RateLimited":{"description":"Too many requests","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}