Quickstart: send your first API request

Prepare the address and API key, verify the service, identity, and repository permissions, and send your first working request.

The first API call only needs a request that returns 200. Complete this path first, then look up specific endpoints.

1. Prepare three things

Requirement Where to get it How to confirm
Service address Printed during deployment, or your Grape domain The home page opens in a browser
API key User settings → API Keys → Generate new key You receive a one-time plaintext value starting with grape_
A repository you have permission for The GitCode / GitHub / Gitee repository list In the form owner/repo

An API key is shown only once, at creation. Put it into secure storage right away; do not paste it into Issues, chat, or code repositories.

2. Confirm the service is online

export GRAPE_BASE_URL="https://<your-domain>"

curl -fsS "$GRAPE_BASE_URL/api/health"

The service is online when server in the response is "ok":

{"server":"ok"}

This step does not validate credentials; it only verifies the network and the address.

3. Put the API key in a header file

Keep the key out of shell history and the process list:

read -rs GRAPE_API_TOKEN
umask 077
AUTH_NAME="Authorization:"
AUTH_SCHEME="Bearer"
echo "$AUTH_NAME $AUTH_SCHEME $GRAPE_API_TOKEN" > ~/.grape.auth

Later requests reference this file directly:

curl -fsS -H @~/.grape.auth "$GRAPE_BASE_URL/api/auth/profile"

Do not put GRAPE_API_TOKEN in command-line arguments. Both ps and shell history can retain it.

4. Verify identity

Call an endpoint that depends only on identity first; do not start with a repository endpoint:

curl -fsS -H @~/.grape.auth "$GRAPE_BASE_URL/api/auth/profile"

Example response:

{
  "username": "<your-username>",
  "status": "online",
  "managed_repos": []
}

GET /api/auth/profile response structure

Seeing username means the key is valid. An empty managed_repos only means no repository is connected yet; it does not mean the key is invalid.

5. Verify repository permissions

Choose a repository the current account has permission for:

export OWNER="<owner>"
export REPO="<repo>"

curl -fsS -H @~/.grape.auth \
  "$GRAPE_BASE_URL/api/issues/$OWNER/$REPO?status=active"

Returns:

{"issues": [], "total": 0}

An empty array is also a success. At this point all three checks are done:

  1. The address is reachable
  2. The key is valid
  3. Repository permissions are correct

6. Troubleshooting a failure

Status Common cause Action
401 Missing header, or the key is revoked Generate a new key; confirm ~/.grape.auth has exactly one complete line
403 Credential type does not match the endpoint scope user_only endpoints do not accept tk_; use grape_ instead
404 Wrong path, or the repository does not exist or is not permitted Check the case of owner/repo and the path
429 Rate limit triggered Wait according to retry_after; do not retry in a loop
400 + API token not configured No usable token is bound on that Git platform yet Complete the binding in platform credentials first

7. Next steps

Completion criteria

  • [ ] /api/health returns server=ok
  • [ ] /api/auth/profile returns your own username
  • [ ] The repository Issue list returns 200
  • [ ] The key does not appear on the command line, in logs, or in the repository
  • [ ] You know what to check first for 401/403/404/429