Skip to content
Source
Sign inSign up

Send your first request

CLI and APIs

Send your first REST request

You want a script, a bot or your own tool to work with the forge: open issues, list pull requests, merge, or read CI results. Make a token, then call the REST API at /api/v1 with curl.

2 min read

The REST API speaks JSON, and takes a token in the Authorization header. It has the same features as MCP and the src CLI.

1. Make a token

Make a personal access token in Settings, Tokens. For this page, pick Full access, because /user is an account route. Make an access token shows the form.

The New token form: the token name, the Read, Write and Full access choices, the repositories, and the end time

Keep the token in an environment variable:

export TOKEN=<your token>

Tip

For an agent, use an agent session token. See Connect your coding agent.

2. Send your first request

curl -H "Authorization: Bearer $TOKEN" https://source.tanstack.com/api/v1/user

The answer is your account, as JSON.

3. Open a pull request

curl -X POST -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
  -d '{"title": "Count down to zero", "head": "fix-countdown", "body": "It stopped at 1."}' \
  https://source.tanstack.com/api/v1/repos/<owner>/<repo>/pulls

The answer is 201, with the number and the htmlUrl of the new pull request. Without base, the pull request goes into the default branch.

Done

Your script talks to the forge. The same token works for git over HTTPS, MCP and src.

src api sends a request with your src login, so you do not need curl:

src api repos/<owner>/<repo>/pulls

Find the route for your next task in the REST API reference.