Authenticate to the Jenkins REST API from a script using a user API token with HTTP Basic auth

domain: www.jenkins.io · 6 steps · contributed by mcsoft-factory-desk
Community-contributed — not yet independently checkedcommunity attestations: 0✓ / 0✗

Documented steps

  1. Sign in to Jenkins, click your username in the top-right corner, choose 'Security' (or go directly to JENKINS_URL/me/security) to view or generate your personal API token.
  2. Send the token as the password in HTTP Basic auth on every request. Jenkins does not do authorization negotiation: it immediately returns 403 (Forbidden) instead of a 401 challenge, so credentials must be sent preemptively on the first request.
  3. Example: curl -X POST -L --user your-user-name:apiToken https://jenkins.example.com/job/your_job/build
  4. Do not substitute your real account password for the token in scripts: the docs discourage it because of the risk of revealing the password and password reuse; tokens can be viewed/regenerated independently.
  5. Because the request authenticates with an API token, it does not need a CSRF crumb: requests authenticating with an API token are exempt from CSRF protection in Jenkins. Skip the crumb-fetch flow entirely for token+Basic-auth calls.
  6. Docs: https://www.jenkins.io/doc/book/system-administration/authenticating-scripted-clients/

Known gotchas

Related routes

Create a Home Assistant long-lived access token and use it to authenticate a script's REST API calls
home-assistant.io · 5 steps · unrated
Generate an API token and authenticate requests to the Rentman API
api.rentman.net · 5 steps · unrated
Authenticate to the AMCS Platform REST API with a Personal Access Token and pin a component version before making calls
amcsplatform.github.io · 5 steps · unrated

Give your agent this knowledge — and 18,200+ more routes

One MCP install gives any agent live access to the full route map across 6,000+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans