{
  "openapi": "3.1.0",
  "info": {
    "title": "Clearly Vectorizer API",
    "version": "1.0.0",
    "description": "Turn a PNG, JPG or WebP into a clean, editable SVG (or PNG, PDF, EPS, DXF). 0.3 credits an image — $0.10 at top-up prices — from your Clearly workspace's credits (plan credits first, then top-ups). Test keys (ck_test_) trace for free with a watermark, 50 calls a month. 10 requests a minute per key. Server-to-server only.",
    "contact": {
      "url": "https://www.clearly.sh/docs/api"
    }
  },
  "servers": [
    {
      "url": "https://relay.clearly.sh"
    }
  ],
  "security": [
    {
      "bearer": []
    }
  ],
  "paths": {
    "/v1/vectorize": {
      "post": {
        "operationId": "vectorize",
        "summary": "Trace an image into a clean, editable SVG",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 255
            },
            "description": "Retry safely: the same key within 24 hours replays the first response."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/VectorizeRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The traced file",
            "headers": {
              "X-Request-Id": {
                "description": "Quote it to support.",
                "schema": {
                  "type": "string"
                }
              },
              "Clearly-Key-Expires": {
                "description": "When the key expires (ISO 8601) — present only for a key with an expiry.",
                "schema": {
                  "type": "string",
                  "format": "date-time"
                }
              },
              "Idempotent-Replayed": {
                "description": "`true` when this is the stored answer to an earlier request with the same Idempotency-Key.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/VectorizeResult"
                }
              }
            }
          },
          "202": {
            "description": "Queued (`async` or `webhookUrl`)",
            "headers": {
              "X-Request-Id": {
                "description": "Quote it to support.",
                "schema": {
                  "type": "string"
                }
              },
              "Clearly-Key-Expires": {
                "description": "When the key expires (ISO 8601) — present only for a key with an expiry.",
                "schema": {
                  "type": "string",
                  "format": "date-time"
                }
              },
              "Idempotent-Replayed": {
                "description": "`true` when this is the stored answer to an earlier request with the same Idempotency-Key.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JobAccepted"
                }
              }
            }
          },
          "400": {
            "description": "The body is missing or malformed, or asks for something the API does not offer",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing, revoked or expired key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "`insufficient_credits` or `key_limit_reached` — nothing ran",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not a Vectorizer API key, or the caller's IP is not on the key's allowlist",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "A request with this Idempotency-Key is still running",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Image larger than 8 MB",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "The trace ran and did not produce a file (refunded), or the Idempotency-Key was used with a different body",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "`rate_limited` (see Retry-After) or `test_limit_reached`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "`busy` or `unavailable` — nothing charged; see Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/jobs/{id}": {
      "get": {
        "operationId": "getJob",
        "summary": "An async job's status and result",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^job_[0-9a-f]{24}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The job",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Job"
                }
              }
            }
          },
          "404": {
            "description": "No such job for this workspace",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/balance": {
      "get": {
        "operationId": "getBalance",
        "summary": "The workspace's credits and this key's month",
        "responses": {
          "200": {
            "description": "Balance",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Balance"
                }
              }
            }
          }
        }
      }
    },
    "/v1/files/{id}": {
      "delete": {
        "operationId": "deleteFile",
        "summary": "Delete a file the API saved to your library",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Deleted"
          },
          "403": {
            "description": "Not a file the API made",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such file",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/status": {
      "get": {
        "operationId": "getStatus",
        "summary": "Public health of the API and its tracers",
        "security": [],
        "responses": {
          "200": {
            "description": "Status"
          }
        }
      }
    },
    "/v1/openapi.json": {
      "get": {
        "operationId": "getOpenApi",
        "summary": "This document",
        "security": [],
        "responses": {
          "200": {
            "description": "OpenAPI 3.1"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearer": {
        "type": "http",
        "scheme": "bearer",
        "description": "A Vectorizer API key: ck_secret_… (live) or ck_test_… (test). Create one at https://www.clearly.sh/portal/api."
      }
    },
    "schemas": {
      "VectorizeRequest": {
        "type": "object",
        "properties": {
          "image": {
            "type": "string",
            "description": "A data: URI — PNG, JPG or WebP, base64, up to 8 MB. Send exactly one of image or imageUrl."
          },
          "imageUrl": {
            "type": "string",
            "format": "uri",
            "description": "A public https URL."
          },
          "format": {
            "type": "string",
            "enum": [
              "svg",
              "png",
              "pdf",
              "eps",
              "dxf"
            ],
            "default": "svg"
          },
          "pngWidth": {
            "type": "integer",
            "minimum": 256,
            "maximum": 4096,
            "default": 2048
          },
          "preset": {
            "type": "string",
            "enum": [
              "logo",
              "clipart",
              "lineart",
              "photo",
              "cut"
            ]
          },
          "colors": {
            "type": "integer",
            "minimum": 2,
            "maximum": 64,
            "description": "Exactly this many colours, from the image's own."
          },
          "mode": {
            "type": "string",
            "enum": [
              "exact"
            ],
            "default": "exact"
          },
          "name": {
            "type": "string",
            "maxLength": 120
          },
          "save": {
            "type": "boolean",
            "default": true,
            "description": "false: not added to your library and not cached."
          },
          "async": {
            "type": "boolean",
            "default": false
          },
          "webhookUrl": {
            "type": "string",
            "format": "uri",
            "description": "A public https URL; implies async."
          }
        }
      },
      "VectorizeResult": {
        "type": "object",
        "properties": {
          "ok": {
            "const": true
          },
          "id": {
            "type": [
              "string",
              "null"
            ]
          },
          "svg": {
            "type": "string"
          },
          "engine": {
            "type": "string"
          },
          "format": {
            "type": "string"
          },
          "creditsCharged": {
            "type": "number"
          },
          "creditsRemaining": {
            "type": [
              "number",
              "null"
            ]
          },
          "test": {
            "type": "boolean"
          },
          "file": {
            "type": "object",
            "properties": {
              "format": {
                "type": "string"
              },
              "contentType": {
                "type": "string"
              },
              "filename": {
                "type": "string"
              },
              "bytes": {
                "type": "integer"
              },
              "base64": {
                "type": "string"
              }
            }
          },
          "requestId": {
            "type": "string"
          }
        }
      },
      "JobAccepted": {
        "type": "object",
        "properties": {
          "ok": {
            "const": true
          },
          "id": {
            "type": "string"
          },
          "status": {
            "const": "queued"
          },
          "statusUrl": {
            "type": "string"
          },
          "requestId": {
            "type": "string"
          }
        }
      },
      "Job": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "status": {
            "enum": [
              "queued",
              "running",
              "succeeded",
              "failed"
            ]
          },
          "httpStatus": {
            "type": "integer"
          },
          "result": {
            "type": "object"
          },
          "webhook": {
            "type": "object"
          }
        }
      },
      "Balance": {
        "type": "object",
        "properties": {
          "credits": {
            "type": "number"
          },
          "planCredits": {
            "type": "number"
          },
          "topupCredits": {
            "type": "number"
          },
          "images": {
            "type": "integer"
          },
          "key": {
            "type": [
              "object",
              "null"
            ]
          }
        }
      },
      "Error": {
        "type": "object",
        "properties": {
          "ok": {
            "const": false
          },
          "error": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "requestId": {
            "type": "string"
          }
        }
      }
    }
  },
  "x-webhooks": {
    "description": "POST to your webhookUrl when a job finishes: { type: \"vectorize.succeeded\" | \"vectorize.failed\", id, createdAt, data }. Header Clearly-Signature: t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\"> with your workspace's webhook secret. Retried with backoff for about seven hours."
  }
}