cobalt api documentation

March 30, 2026 ยท View on GitHub

methods, acceptable values, headers, responses and everything else related to making and parsing requests from a cobalt api instance.

Important

hosted api instances (such as api.cobalt.tools) use bot protection and are not intended to be used in other projects without explicit permission. if you want to use the cobalt api, you should host your own instance or ask an instance owner for access.

all endpoints (except for GET /) are rate limited and return current rate limiting status in RateLimit-* headers, according to the "RateLimit Header Fields for HTTP" spec.

authentication

an api instance may be configured to require you to authenticate yourself. if this is the case, you will typically receive an error response with a api.auth.<method>.missing code, which tells you that a particular method of authentication is required.

authentication is done by passing the Authorization header, containing the authentication scheme and the token:

Authorization: <scheme> <token>

currently, cobalt supports two ways of authentication. an instance can choose to configure both, or neither:

api-key authentication

the api key authentication is the most straightforward. the instance owner will assign you an api key which you can then use to authenticate like so:

Authorization: Api-Key aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee

if you are an instance owner and wish to configure api key authentication, see the instance documentation!

bearer authentication

the cobalt server may be configured to issue JWT bearers, which are short-lived tokens intended for use by regular users (e.g. after passing a challenge). currently, cobalt can issue tokens for successfully solved turnstile challenge, if the instance has turnstile configured. the resulting token is passed like so:

Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...

POST /

cobalt's main processing endpoint.

Important

you must include correct Accept and Content-Type headers with every POST / request.

Accept: application/json
Content-Type: application/json

request body

body type: application/json

not a fan of reading tables of text? you can read the api schema directly from code instead!

api schema

all keys except for url are optional. value options are separated by /.

general

keytypedescription/valuedefault
urlstringsource URLrequired
audioBitratestring320 / 256 / 128 / 96 / 64 / 8 (kbps)128
audioFormatstringbest / mp3 / ogg / wav / opusmp3
downloadModestringauto / audio / muteauto
filenameStylestringclassic / pretty / basic / nerdybasic
videoQualitystringmax / 4320 / 2160 / 1440 / 1080 / 720 / 480 / 360 / 240 / 1441080
disableMetadatabooleantitle, artist, and other info will not be added to the filefalse
alwaysProxybooleanalways tunnel all files, even when not necessaryfalse
localProcessingstringdisabled / preferred / forceddisabled
subtitleLangstringany valid ISO 639-1 language codenone

service-specific options

keytypedescription/valuedefault
youtubeVideoCodecstringh264 / av1 / vp9h264
youtubeVideoContainerstringauto / mp4 / webm / mkvauto
youtubeDubLangstringany valid ISO 639-1 language codenone
convertGifbooleanconvert twitter gifs to the actual GIF formattrue
allowH265booleanallow H265/HEVC videos from tiktokfalse
tiktokFullAudiobooleandownload the original sound used in a videofalse
youtubeBetterAudiobooleanprefer higher quality youtube audio if possiblefalse
youtubeHLSbooleanuse HLS formats when downloading from youtubefalse

response

body type: application/json

the response will always be a JSON object containing the status key, which is one of:

  • tunnel: cobalt is proxying and/or remuxing/transcoding the file for you.
  • local-processing: cobalt is proxying the files for you, but you have to remux/transcode them locally.
  • redirect: cobalt will redirect you to the direct service URL.
  • picker: there are multiple items to choose from, a picker should be shown.
  • error: something went wrong, here's an error code.

tunnel/redirect response

keytypevalue
statusstringtunnel / redirect
urlstringurl for the cobalt tunnel, or redirect to an external link
filenamestringcobalt-generated filename for the file being downloaded

local processing response

keytypevalue
statusstringlocal-processing
typestringmerge, mute, audio, gif, or remux
servicestringorigin service (youtube, twitter, instagram, etc)
tunnelstring[]array of tunnel URLs
outputobjectdetails about the output file (see below)
audioobjectaudio-specific details (optional, see below)
isHLSbooleanwhether the output is in HLS format (optional)

output object

keytypevalue
typestringmime type of the output file
filenamestringfilename of the output file
metadataobjectmetadata associated with the file (optional, see below)
subtitlesbooleanwhether tunnels include a subtitle file

output.metadata object

all keys in this table are optional.

keytypedescription
albumstringalbum name or collection title
composerstringcomposer of the track
genrestringtrack's genre(s)
copyrightstringcopyright information or ownership details
titlestringtitle of the track or media file
artiststringartist or creator name
album_artiststringalbum's artist or creator name
trackstringtrack number or position in album
datestringrelease date or creation date
sublanguagestringsubtitle language code (ISO 639-2)

audio object

keytypevalue
copybooleandefines whether audio codec data is copied
formatstringoutput audio format
bitratestringpreferred bitrate of audio format
coverbooleanwhether tunnels include a cover art file (optional)
cropCoverbooleanwhether cover art should be cropped to a square (optional)

picker response

keytypevalue
statusstringpicker
audiostringreturned when an image slideshow (such as on tiktok) has a general background audio (optional)
audioFilenamestringcobalt-generated filename, returned if audio exists (optional)
pickerarrayarray of objects containing the individual media

picker object

keytypevalue
typestringphoto / video / gif
urlstring
thumbstringthumbnail url (optional)

error response

keytypevalue
statusstringerror
errorobjecterror code & optional context

error object

keytypevalue
codestringmachine-readable error code explaining the failure reason
contextobjectadditional error context (optional)

error.context object

keytypevalue
servicestringorigin service (optional)
limitnumberthe maximum downloadable video duration or the rate limit window (optional)

POST /session

used for generating JWT tokens, if enabled. currently, cobalt only supports generating tokens when a turnstile challenge solution is submitted by the client.

the turnstile challenge response is submitted via the cf-turnstile-response header.

response body

keytypedescription
tokenstringa Bearer token used for later request authentication
expnumbernumber in seconds indicating the token lifetime

on failure, an error response is returned.

GET /

provides basic instance info.

response

body type: application/json

keytypedescription
cobaltobjectinformation about the cobalt instance
gitobjectinformation about the codebase that is currently running

cobalt object

keytypedescription
versionstringcobalt version
urlstringinstance url
startTimestringinstance start time in unix milliseconds
turnstileSitekeystringsite key for a turnstile widget (optional)
servicesstring[]array of services which this instance supports

git object

keytypedescription
commitstringcommit hash
branchstringgit branch
remotestringgit remote

GET /tunnel

endpoint for file tunnels (proxy/remux/transcode). the response is a file stream. all errors are reported via HTTP status codes.

returned headers

  • Content-Length: file size, in bytes. returned when exact final file size is known.
  • Estimated-Content-Length: estimated file size, in bytes. returned when real Content-Length is not known. a rough estimate which should NOT be used for strict size verification. can be used to show approximate download progress in UI.

possible HTTP status codes

  • 200: OK
  • 401: Unauthorized
  • 403: Bad Request
  • 404: Not Found
  • 429: Too Many Requests (rate limit exceeded, check RateLimit-* headers)
  • 500: Internal Server Error.