{
  "openapi": "3.1.0",
  "info": {
    "title": "Deprint API",
    "version": "1.0.0",
    "description": "Private metadata exports, scoped keys, prepaid credits and Cosmo jobs. SynthID processing is currently unavailable.",
    "contact": {
      "email": "support@deprint.ai"
    }
  },
  "servers": [
    {
      "url": "https://deprint.ai/api/v1"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/account": {
      "get": {
        "summary": "Read credit balance and lifetime usage",
        "description": "Required scope: account:read.",
        "operationId": "get_account",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "Invalid authentication"
          },
          "403": {
            "description": "Insufficient permission"
          },
          "429": {
            "description": "Account rate or storage limit. Respect Retry-After."
          },
          "503": {
            "description": "Service or processing unavailable"
          }
        }
      }
    },
    "/usage": {
      "get": {
        "summary": "Read total and daily usage",
        "description": "Required scope: account:read.",
        "operationId": "get_usage",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "Invalid authentication"
          },
          "403": {
            "description": "Insufficient permission"
          },
          "429": {
            "description": "Account rate or storage limit. Respect Retry-After."
          },
          "503": {
            "description": "Service or processing unavailable"
          }
        },
        "parameters": [
          {
            "in": "query",
            "name": "since",
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "description": "Inclusive timestamp"
          },
          {
            "in": "query",
            "name": "until",
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "description": "Exclusive timestamp"
          }
        ]
      }
    },
    "/keys": {
      "get": {
        "summary": "List active API keys",
        "description": "Required scope: keys:write.",
        "operationId": "get_keys",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "Invalid authentication"
          },
          "403": {
            "description": "Insufficient permission"
          },
          "429": {
            "description": "Account rate or storage limit. Respect Retry-After."
          },
          "503": {
            "description": "Service or processing unavailable"
          }
        }
      },
      "post": {
        "summary": "Create a key; full key is returned once",
        "description": "Required scope: keys:write.",
        "operationId": "post_keys",
        "responses": {
          "201": {
            "description": "Key created; save the secret now"
          },
          "403": {
            "description": "Cannot delegate a scope the caller does not hold"
          },
          "429": {
            "description": "20 active key limit"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 80
                  },
                  "scopes": {
                    "type": "array",
                    "minItems": 1,
                    "uniqueItems": true,
                    "items": {
                      "enum": [
                        "account:read",
                        "images:read",
                        "images:write",
                        "jobs:read",
                        "jobs:write",
                        "keys:write",
                        "billing:write"
                      ]
                    }
                  }
                },
                "required": [
                  "name",
                  "scopes"
                ]
              }
            }
          }
        }
      }
    },
    "/keys/{id}": {
      "delete": {
        "summary": "Revoke an API key",
        "description": "Required scope: keys:write.",
        "operationId": "delete_keys__id_",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "Invalid authentication"
          },
          "403": {
            "description": "Insufficient permission"
          },
          "429": {
            "description": "Account rate or storage limit. Respect Retry-After."
          },
          "503": {
            "description": "Service or processing unavailable"
          }
        },
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ]
      }
    },
    "/images": {
      "get": {
        "summary": "List up to 100 owned images",
        "description": "Required scope: images:read.",
        "operationId": "get_images",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "Invalid authentication"
          },
          "403": {
            "description": "Insufficient permission"
          },
          "429": {
            "description": "Account rate or storage limit. Respect Retry-After."
          },
          "503": {
            "description": "Service or processing unavailable"
          }
        }
      },
      "post": {
        "summary": "Upload and export an image for one credit",
        "description": "Required scope: images:write.",
        "operationId": "post_images",
        "responses": {
          "200": {
            "description": "Previous result; no additional charge"
          },
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "image": {
                      "$ref": "#/components/schemas/Image"
                    }
                  }
                }
              }
            }
          },
          "202": {
            "description": "An existing request is still running; poll statusUrl without changing Idempotency-Key"
          },
          "402": {
            "description": "Insufficient credits or frozen balance"
          },
          "409": {
            "description": "Conflicting or in-progress request"
          },
          "410": {
            "description": "Export for this key was deleted"
          },
          "413": {
            "description": "Upload too large"
          },
          "503": {
            "description": "Retry with the same idempotency key"
          }
        },
        "parameters": [
          {
            "in": "header",
            "name": "Idempotency-Key",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128
            },
            "description": "Stable unique request key; reuse only when retrying identical input."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "required": [
                  "file"
                ],
                "properties": {
                  "file": {
                    "type": "string",
                    "format": "binary",
                    "description": "JPEG, PNG or WebP. Maximum 3 MiB and 25 megapixels."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/images/{id}": {
      "get": {
        "summary": "Read an owned image and refresh signed URLs",
        "description": "Required scope: images:read.",
        "operationId": "get_images__id_",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "Invalid authentication"
          },
          "403": {
            "description": "Insufficient permission"
          },
          "429": {
            "description": "Account rate or storage limit. Respect Retry-After."
          },
          "503": {
            "description": "Service or processing unavailable"
          }
        },
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ]
      },
      "delete": {
        "summary": "Delete original, export and image record",
        "description": "Required scope: images:write.",
        "operationId": "delete_images__id_",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "Invalid authentication"
          },
          "403": {
            "description": "Insufficient permission"
          },
          "429": {
            "description": "Account rate or storage limit. Respect Retry-After."
          },
          "503": {
            "description": "Service or processing unavailable"
          }
        },
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ]
      }
    },
    "/images/{id}/download": {
      "get": {
        "summary": "Download a saved export without another charge",
        "description": "Required scope: images:read.",
        "operationId": "get_images__id__download",
        "responses": {
          "302": {
            "description": "Follow Location to a private URL valid for five minutes"
          },
          "404": {
            "description": "No owned image found"
          }
        },
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ]
      }
    },
    "/jobs": {
      "get": {
        "summary": "List up to 100 recent owned jobs",
        "description": "Required scope: jobs:read.",
        "operationId": "get_jobs",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "Invalid authentication"
          },
          "403": {
            "description": "Insufficient permission"
          },
          "429": {
            "description": "Account rate or storage limit. Respect Retry-After."
          },
          "503": {
            "description": "Service or processing unavailable"
          }
        }
      },
      "post": {
        "summary": "Request SynthID processing",
        "description": "Required scope: jobs:write.",
        "operationId": "post_jobs",
        "responses": {
          "404": {
            "description": "Source image not found"
          },
          "409": {
            "description": "Idempotency conflict"
          },
          "503": {
            "description": "Processor unavailable; no credits charged",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "const": "processing_unavailable"
                    },
                    "job": {
                      "$ref": "#/components/schemas/Job"
                    }
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "in": "header",
            "name": "Idempotency-Key",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128
            },
            "description": "Stable unique request key; reuse only when retrying identical input."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "imageId": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "operation": {
                    "const": "synthid_remove"
                  }
                },
                "required": [
                  "imageId",
                  "operation"
                ]
              }
            }
          }
        }
      }
    },
    "/jobs/{id}": {
      "get": {
        "summary": "Read processing status",
        "description": "Required scope: jobs:read.",
        "operationId": "get_jobs__id_",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "Invalid authentication"
          },
          "403": {
            "description": "Insufficient permission"
          },
          "429": {
            "description": "Account rate or storage limit. Respect Retry-After."
          },
          "503": {
            "description": "Service or processing unavailable"
          }
        },
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ]
      }
    },
    "/jobs/{id}/cancel": {
      "post": {
        "summary": "Cancel an unavailable or queued job",
        "description": "Required scope: jobs:write.",
        "operationId": "post_jobs__id__cancel",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "Invalid authentication"
          },
          "403": {
            "description": "Insufficient permission"
          },
          "429": {
            "description": "Account rate or storage limit. Respect Retry-After."
          },
          "503": {
            "description": "Service or processing unavailable"
          }
        },
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ]
      }
    },
    "/billing": {
      "get": {
        "summary": "Read prices, purchase availability and receipts",
        "description": "Required scope: account:read.",
        "operationId": "get_billing",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "Invalid authentication"
          },
          "403": {
            "description": "Insufficient permission"
          },
          "429": {
            "description": "Account rate or storage limit. Respect Retry-After."
          },
          "503": {
            "description": "Service or processing unavailable"
          }
        }
      }
    },
    "/billing/checkout": {
      "post": {
        "summary": "Create a hosted one-time credit checkout",
        "description": "Required scope: billing:write.",
        "operationId": "post_billing_checkout",
        "responses": {
          "201": {
            "description": "Open the URL to approve payment; balance is updated after verified confirmation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "url": {
                      "type": "string",
                      "format": "uri"
                    },
                    "expiresAt": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Purchases disabled or unavailable"
          }
        },
        "parameters": [
          {
            "in": "header",
            "name": "Idempotency-Key",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128
            },
            "description": "Stable unique request key; reuse only when retrying identical input."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "pack": {
                    "const": "credits_1000"
                  }
                },
                "required": [
                  "pack"
                ]
              }
            }
          }
        }
      }
    },
    "/exports/{idempotencyKey}": {
      "get": {
        "summary": "Recover an export after a lost response",
        "description": "Required scope: images:write.",
        "operationId": "get_exports__idempotencyKey_",
        "responses": {
          "200": {
            "description": "Completed export",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "state": {
                      "const": "complete"
                    },
                    "upload": {
                      "$ref": "#/components/schemas/Image"
                    }
                  }
                }
              }
            }
          },
          "202": {
            "description": "Still running; retain the key and respect Retry-After"
          },
          "401": {
            "description": "Invalid authentication"
          },
          "403": {
            "description": "Missing images:write scope"
          },
          "404": {
            "description": "Unknown or unowned request"
          },
          "409": {
            "description": "Reservation refunded; a new request key may be used"
          },
          "410": {
            "description": "Completed export was deleted"
          }
        },
        "parameters": [
          {
            "in": "path",
            "name": "idempotencyKey",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200
            }
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "Deprint API key"
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "string"
          },
          "code": {
            "type": "string"
          }
        }
      },
      "Image": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "state": {
            "const": "complete"
          },
          "result": {
            "type": "object",
            "properties": {
              "metadata": {
                "const": "removed"
              },
              "synthid": {
                "const": "not_processed"
              }
            }
          },
          "downloadUrl": {
            "type": "string",
            "format": "uri"
          },
          "previewUrl": {
            "type": "string",
            "format": "uri"
          },
          "hash": {
            "type": "string"
          },
          "outputHash": {
            "type": "string"
          }
        }
      },
      "Job": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "imageId": {
            "type": "string",
            "format": "uuid"
          },
          "operation": {
            "const": "synthid_remove"
          },
          "state": {
            "enum": [
              "unavailable",
              "queued",
              "leased",
              "processing",
              "complete",
              "failed",
              "canceled"
            ]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      }
    }
  }
}
