curl bearer token: how to send the Authorization header
Send a bearer token with curl in an Authorization: Bearer header, in double quotes so $TOKEN expands, or use --oauth2-bearer. Fixes for each 401.

To send a bearer token with curl, put it in an Authorization header: curl -H "Authorization: Bearer $TOKEN" https://api.example.com/.... Use double quotes so the shell expands $TOKEN, and leave a space between Bearer and the token. curl's --oauth2-bearer "$TOKEN" option is the built-in alternative: you pass only the token.
curl's options are quoted from its man page and everything curl, shell quoting from the Bash manual's single quotes and double quotes pages, and the header format from RFC 6750, all read 2026-09-28. The Sume examples follow its Authentication docs; its 401 messages are read from the current API code.
How do I pass a bearer token in a curl command?
Keep the token in an environment variable and reference it inside double quotes. RFC 6750 defines the header as the word Bearer, at least one space, then the token, and says a client must not send the token by more than one method in the same request. curl's --oauth2-bearer formats the token according to RFC 6750, so you leave out the Bearer prefix.
Sume API keys follow the same rule: send one as Authorization: Bearer or as x-api-key, never both. How Sume API keys work covers scopes and hosts. Both commands below send the key as a bearer token:
export SUME_API_KEY="sume_live_..."
curl https://api.sume.com/v1/me \
-H "Authorization: Bearer $SUME_API_KEY"
curl https://api.sume.com/v1/me --oauth2-bearer "$SUME_API_KEY"Why does curl with a bearer token return 401?
Usually because the header that arrived isn't the one you meant, or the server no longer accepts the token. Add -v to see the header: curl prints each header it sends on a line starting with >, token included, so keep that output out of tickets and screenshots.
A 403 is a different problem: the key was accepted but lacks a permission, as 401 vs 403 vs 404 explains. On the Sume API, each 401 mistake gets its own message in current code:
| What curl sent | Sume's 401 message | Fix |
|---|---|---|
No Authorization or x-api-key header | Missing API key. Send x-api-key or Authorization: Bearer. | Add the header. |
Bearer with nothing after it, from an unset or empty variable | Authorization header must use Bearer authentication. | Export the variable in the shell that runs curl. |
The token without Bearer, or another scheme such as Token | Authorization header must use Bearer authentication. | Put Bearer before the token. |
| A token with a space inside it | Malformed Authorization header. | Copy the token again, without whitespace. |
Both Authorization: Bearer and x-api-key | Send only one API key credential. | Remove one of them. |
The text $SUME_API_KEY itself, or an unknown or revoked key | Missing or invalid API key. | Use double quotes, or create a new key. |
Should I use double or single quotes around the header?
Double quotes, when the token is in a variable. The Bash manual says single quotes preserve the literal value of each character inside them, so 'Authorization: Bearer $SUME_API_KEY' sends the text $SUME_API_KEY. Inside double quotes, $ keeps its special meaning and the variable expands.
On Windows, everything curl notes there is no support for single quotes, and in PowerShell an alias can run another tool when you type curl, so type curl.exe.
To make a missing variable fail loudly instead of sending an empty token, curl 8.3.0 and later can import it: --variable '%SUME_API_KEY' exits with an error if the variable isn't set, and --expand-header "Authorization: Bearer {{SUME_API_KEY}}" inserts its value.
How do I keep the token safe while testing?
Treat any bearer token the way Sume's docs treat API keys: never in frontend JavaScript, mobile apps, support tickets, or screenshots. Where to store API keys covers the safe places. Two curl habits help while you test:
-H @filereads headers from a file, one per line, so the token never appears on the command line.- With
-L, curl doesn't pass anAuthorizationheader on to a redirect that goes to another origin unless you add--location-trusted. Downloading a generated video shows where that matters on Sume.
Sources
Related posts
More in Developers
- Do you need a GPU for AI video? Only to run the model
You need a GPU for AI video only if you run the model yourself. A hosted video API needs none: your code sends HTTPS and downloads an MP4.
- Does Runway have an API? Yes: how Runway Dev works
Yes. Runway's developer platform has an HTTP API with Node and Python SDKs: start a task, poll it, read the output. Models, routers and costs.
- fal.ai and Replicate alternatives for AI video generation
The alternatives to fal.ai and Replicate for AI video generation: Kling's and Runway's own APIs, Higgsfield, and Sume, compared on models and billing.
- fal.ai vs Higgsfield: developer API or creative suite?
fal is a developer platform billed per output; Higgsfield is a creative suite with apps and an agent that also sells an API. How they compare.
Written by Sume