Skip to content
Latchkey

curl -A / --user-agent: Set the User-Agent

Some APIs reject requests with no or a default User-Agent, GitHub among them.

Setting a clear User-Agent identifies your pipeline and satisfies APIs that require one. It is a one-flag fix for a class of mysterious 403s.

What it does

-A / --user-agent <string> sets the User-Agent request header. By default curl sends a User-Agent like curl/8.x. Some APIs require a meaningful User-Agent and reject requests without one. -A is a shortcut for -H 'User-Agent: ...'; either works, but -A is clearer.

Common usage

Terminal
curl -A 'ci-bot/1.0' https://api.example.com/x
curl -A 'owner-ci' https://api.github.com/repos/owner/repo
# equivalent with -H
curl -H 'User-Agent: ci-bot/1.0' https://api.example.com/x

Flags

FlagWhat it does
-A / --user-agent <s>Set the User-Agent header
-H 'User-Agent: ...'Equivalent via the generic header flag
-A ''Send an empty User-Agent

In CI

Use a descriptive User-Agent like your-org-ci so logs and rate-limit dashboards on the API side can identify your pipeline. For the GitHub API in particular, a missing User-Agent is rejected, so set one on every call. Keep it stable so the API owner can allowlist it if needed.

Common errors in CI

A 403 with "Request forbidden by administrative rules ... must supply a User-Agent" from the GitHub API means you sent no User-Agent; add -A. Some WAFs block the default curl/8.x agent, which also surfaces as a 403.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →