# API reference

> Every endpoint of the ImgSearch API, version 2.0.0, from its OpenAPI document.

Base URL: `https://imgsearch.com/api/v2`. Send `Authorization: Bearer <API key or OAuth token>` on every call but the public ones, and JSON bodies with `Content-Type: application/json`. Every answer is JSON (files, redirects and the YAML spec aside) and carries `X-Request-Id` and `ImgSearch-Api-Version: 2.0.0`. The OpenAPI document is at `https://imgsearch.com/api/v2/openapi.yaml` and `https://imgsearch.com/api/v2/openapi.json`. Errors: [error codes](https://imgsearch.com/developers/errors.md). Limits: [rate and crawl limits](https://imgsearch.com/developers/limits.md).

## Meta

The API itself, its status and this document.

- `GET /` [What this API is and where its documents are](https://imgsearch.com/developers/reference/meta.md#index)
- `GET /status` [Whether the AI Generator takes work now, and which models are paused](https://imgsearch.com/developers/reference/meta.md#status)
- `GET /openapi.json` [This document as JSON](https://imgsearch.com/developers/reference/meta.md#openapi.json)
- `GET /openapi.yaml` [This document as YAML](https://imgsearch.com/developers/reference/meta.md#openapi.yaml)

## Models

The AI Generator's models and their prices in US dollars.

- `GET /models` [The Generator's models, with their price range in US dollars](https://imgsearch.com/developers/reference/models.md#models.index)
- `GET /models/{id}` [One model, with its options and price table for each kind it serves](https://imgsearch.com/developers/reference/models.md#models.show)

## Licenses

What each source's files may be used for.

- `GET /licenses` [What the files of each source may be used for](https://imgsearch.com/developers/reference/licenses.md#licenses)

## Account

The account behind the key or token.

- `GET /account` [The account behind the key or token, and the connection itself](https://imgsearch.com/developers/reference/account.md#account)
- `GET /account/balance` [The AI balance in US dollars, by source and lot](https://imgsearch.com/developers/reference/account.md#account.balance)
- `GET /account/balance/transactions` [The AI balance's ledger in US dollars, newest first](https://imgsearch.com/developers/reference/account.md#account.transactions)
- `GET /account/limits` [How the account stands against its limits right now](https://imgsearch.com/developers/reference/account.md#account.limits)
- `GET /account/savings` [What this account's agents reused instead of generating](https://imgsearch.com/developers/reference/account.md#account.savings)

## Search

One search over every public source, with comparable scores and what generating instead would cost.

- `POST /search` [Search every public source at once](https://imgsearch.com/developers/reference/search.md#search)
- `GET /previews/{token}` [Open a search result's preview](https://imgsearch.com/developers/reference/search.md#previews.show)

## Assets

One asset's card.

- `GET /assets/{type}/{id}` [One asset's card](https://imgsearch.com/developers/reference/assets.md#assets.show)

## Downloads

Files and signed links, counted under fair use only when delivered; the download history.

- `GET /assets/{type}/{id}/file` [Download one file](https://imgsearch.com/developers/reference/downloads.md#assets.file)
- `POST /downloads` [Signed download links for up to 20 items](https://imgsearch.com/developers/reference/downloads.md#downloads.store)
- `GET /account/downloads` [The account's download history, newest first](https://imgsearch.com/developers/reference/downloads.md#account.downloads)
- `GET /files/{token}` [Fetch a signed download link](https://imgsearch.com/developers/reference/downloads.md#files.show)

## Generations

The AI Generator, for keys made with spending allowed: estimate, start (Idempotency-Key and max_usd), poll, cancel, the files by 10-minute links, the free side actions and uploads.

- `POST /generations/estimate` [What a generation would cost, and whether this key could start it now](https://imgsearch.com/developers/reference/generations.md#generations.estimate)
- `GET /generations` [Your generations, newest first](https://imgsearch.com/developers/reference/generations.md#generations.index)
- `POST /generations` [Start a generation (spends AI balance)](https://imgsearch.com/developers/reference/generations.md#generations.store)
- `POST /uploads` [Upload a picture to use as a reference](https://imgsearch.com/developers/reference/generations.md#uploads.store)
- `GET /generations/{id}` [One generation](https://imgsearch.com/developers/reference/generations.md#generations.show)
- `DELETE /generations/{id}` [Delete a finished generation and its files](https://imgsearch.com/developers/reference/generations.md#generations.destroy)
- `PATCH /generations/{id}` [Rename, star, or change a meme's captions](https://imgsearch.com/developers/reference/generations.md#generations.update)
- `POST /generations/{id}/cancel` [Cancel a generation that has not started](https://imgsearch.com/developers/reference/generations.md#generations.cancel)
- `GET /generations/{id}/outputs/{n}` [An output's file, to the bearer](https://imgsearch.com/developers/reference/generations.md#generations.outputs)
- `POST /generations/{id}/upscale` [Upscale one of a generation's pictures 2× (spends AI balance)](https://imgsearch.com/developers/reference/generations.md#generations.upscale)
- `POST /generations/{id}/exports` [A 3D model in another format (free)](https://imgsearch.com/developers/reference/generations.md#generations.exports.store)
- `GET /generations/{id}/exports/{key}` [One export's state and links](https://imgsearch.com/developers/reference/generations.md#generations.exports.show)
- `POST /generations/{id}/ar` [View a 3D model in AR (free)](https://imgsearch.com/developers/reference/generations.md#generations.ar)
- `POST /generations/{id}/soundtrack` [Put one of your tracks (and a voiceover) on a clip (free)](https://imgsearch.com/developers/reference/generations.md#generations.soundtrack)
- `POST /generations/{id}/voiceover-video` [Lay a finished voiceover on one of your clips (free)](https://imgsearch.com/developers/reference/generations.md#generations.voiceover-video)
- `GET /generation-files/{token}` [Fetch one of your generation files by its signed link](https://imgsearch.com/developers/reference/generations.md#generation-files.show)
- `PUT /upload-links/{token}` [Upload a reference picture to a signed upload link](https://imgsearch.com/developers/reference/generations.md#upload-links.store)

## Webhooks

The account's events feed and the webhook endpoints they are sent to, signed as Standard Webhooks; the low-balance alert.

- `GET /events` [The account's events, oldest first](https://imgsearch.com/developers/reference/webhooks.md#events.index)
- `GET /events/settings` [The low-balance alert](https://imgsearch.com/developers/reference/webhooks.md#events.settings)
- `PATCH /events/settings` [Set or turn off the low-balance alert](https://imgsearch.com/developers/reference/webhooks.md#events.settings.update)
- `GET /webhooks` [Your webhook endpoints](https://imgsearch.com/developers/reference/webhooks.md#webhooks.index)
- `POST /webhooks` [Add an endpoint](https://imgsearch.com/developers/reference/webhooks.md#webhooks.store)
- `GET /webhooks/{id}` [One endpoint](https://imgsearch.com/developers/reference/webhooks.md#webhooks.show)
- `DELETE /webhooks/{id}` [Delete an endpoint and its delivery log](https://imgsearch.com/developers/reference/webhooks.md#webhooks.destroy)
- `PATCH /webhooks/{id}` [Change an endpoint, or turn it off or on](https://imgsearch.com/developers/reference/webhooks.md#webhooks.update)
- `POST /webhooks/{id}/test` [Send a webhook.test event](https://imgsearch.com/developers/reference/webhooks.md#webhooks.test)
- `POST /webhooks/{id}/rotate-secret` [A new signing secret](https://imgsearch.com/developers/reference/webhooks.md#webhooks.rotate-secret)
- `GET /webhooks/{id}/deliveries` [An endpoint's delivery log, newest first](https://imgsearch.com/developers/reference/webhooks.md#webhooks.deliveries)
- `POST /webhooks/{id}/deliveries/{eventId}/redeliver` [Send an event to this endpoint again](https://imgsearch.com/developers/reference/webhooks.md#webhooks.redeliver)
