# HackerGPT API

Canonical: https://hackergpt.org/docs/api/

Send prompts to HackerGPT from your own scripts and tools. The API is plain HTTPS and JSON: you send a message, then poll until the answer is ready.

**Base URL:** `https://hackergpt.app/api/v1`

## Authentication

Your account token is your API key. You get it once, when you create an anonymous account at [hackergpt.app](https://hackergpt.app). Save it then: we store only a hash, so we cannot look it up or recover it for you.

Send it on every request:

```http
Authorization: Anon 3f9a7c1e-5b2d-4086-a9e1-c7f2b8d05e64
```

Treat the token like a password. If it leaks, replace it with [POST /account/rotate/](https://hackergpt.org/docs/api/#rotate-token).

## Quick start

The token and IDs in the examples are fake. Replace them with your own.

### 1\. Send a message

```bash
curl -X POST https://hackergpt.app/api/v1/messages/ \
  -H "Authorization: Anon 3f9a7c1e-5b2d-4086-a9e1-c7f2b8d05e64" \
  -H "Content-Type: application/json" \
  -d '{"message": "check cybergym.hackergpt.app", "tool": "ctf"}'
```

It returns at once, with `202 Accepted`:

Response

```json
{
  "message_id": 48213,
  "session_id": 7350,
  "status": "pending",
  "poll_url": "/api/v1/messages/48213/",
  "prompt": "check cybergym.hackergpt.app",
  "response": null,
  "created_at": "2026-11-21T14:05:32.418204Z"
}
```

Keep `message_id` to get the answer, and `session_id` to continue the conversation.

### 2\. Poll until the status is no longer pending

```bash
curl https://hackergpt.app/api/v1/messages/48213/ \
  -H "Authorization: Anon 3f9a7c1e-5b2d-4086-a9e1-c7f2b8d05e64"
```

- `pending`: the agent is still working. Ask again in 5–30 seconds. A run takes from a few seconds to about 20 minutes (long CTF solves).
- `done`: the answer is in `response`.
- `failed`: `response` holds the error text.

A ready-made loop is in [Examples](https://hackergpt.org/docs/api/#examples).

### 3\. Continue the conversation

```bash
curl -X POST https://hackergpt.app/api/v1/messages/ \
  -H "Authorization: Anon 3f9a7c1e-5b2d-4086-a9e1-c7f2b8d05e64" \
  -H "Content-Type: application/json" \
  -d '{"message": "now list its open ports", "session_id": 7350}'
```

Leave `session_id` out to start a new session.

## Agents

The `tool` field picks the agent for a session. It is read only on the session's first message; later messages keep the same agent. Without `tool`, the default agent answers. The API never picks an agent for you.

| tool | What the agent does |
| --- | --- |
| `ctf` | Solves CTF challenges on a web app: maps the app and tests it for SQL injection, XSS, broken access control and similar bugs. [Field guide](https://hackergpt.org/docs/ctf/) |
| `osint` | Gathers information from open sources: domains, subdomains, IP addresses, WHOIS, CVEs, the dark web, image metadata, crypto wallets. |
| `browser` | Opens a URL in a browser and collects its network logs. |

Prompts to try with each agent are in the [documentation](https://hackergpt.org/docs/).

## Endpoints

| Method | Path | What it does |
| --- | --- | --- |
| `POST` | `/messages/` | Send a message. Opens a new session if `session_id` is left out. |
| `GET` | `/messages/{message_id}/` | Status and result of one message. |
| `GET` | `/sessions/` | Your 100 most recent sessions. |
| `GET` | `/sessions/{session_id}/messages/` | Every message in a session, oldest first. |
| `GET` | `/account/` | Credits, entitlements and account state. |
| `POST` | `/account/rotate/` | Replace your token. The old one stops working at once. |
| `DELETE` | `/account/` | Delete the account and all its data. |

### Request body: POST /messages/

| Field | Type | Required | Notes |
| --- | --- | --- | --- |
| `message` | string | yes | Your prompt. Up to 32,000 characters. |
| `session_id` | integer | no | Continue this session. Unknown or not yours: `404`. |
| `tool` | string | no | `ctf`, `osint` or `browser`. See [Agents](https://hackergpt.org/docs/api/#agents). |
| `target` | string | no | Target for the run, up to 255 characters. Read only when the session is created. |

### Message object

Returned when you send a message, when you poll it, and in a session's message list.

| Field | Meaning |
| --- | --- |
| `message_id` | ID of the message. Use it to poll. |
| `session_id` | ID of the session. Send it back to continue the conversation. |
| `status` | `pending`, `done` or `failed`. |
| `response` | The answer when `done`, the error text when `failed`, otherwise `null`. |
| `poll_url` | Path to poll, relative to `https://hackergpt.app`. |
| `prompt` | What you sent. |
| `created_at` | When you sent it, in UTC. |

A finished message

```json
{
  "message_id": 48213,
  "session_id": 7350,
  "status": "done",
  "poll_url": "/api/v1/messages/48213/",
  "prompt": "check cybergym.hackergpt.app",
  "response": "…the agent's answer…",
  "created_at": "2026-11-21T14:05:32.418204Z"
}
```

### Rotate the token: POST /account/rotate/

```bash
curl -X POST https://hackergpt.app/api/v1/account/rotate/ \
  -H "Authorization: Anon 3f9a7c1e-5b2d-4086-a9e1-c7f2b8d05e64"
```

Response

```json
{"uuid": "NEW_TOKEN", "account": {...}}
```

This is the only time the new token is shown. Save it before you do anything else.

## Credits

Each message costs one credit, taken when the run starts. A run that dies without producing an answer is refunded.

Check your balance in `credits`, and whether you can send right now in `can_send`:

```bash
curl https://hackergpt.app/api/v1/account/ \
  -H "Authorization: Anon 3f9a7c1e-5b2d-4086-a9e1-c7f2b8d05e64"
```

Buy more credits in the [web app](https://hackergpt.app).

## Limits

- **30 requests per minute** per account, across all endpoints.
- **3 runs in flight** at once. Wait for one to finish before starting another.

## Errors

Errors are JSON with a human-readable `detail` and, where useful, a machine-readable `reason`.

| Status | When | reason |
| --- | --- | --- |
| `400` | Invalid body. Field errors are keyed by field name. | — |
| `401` | Missing or invalid token. | — |
| `402` | Can't send: out of credits or over a plan limit. Also returns `credits_remaining`. | `no_credits`, `free_limit`, `ctf_limit`, `sub_expired` |
| `403` | `DELETE /account/` is not allowed for this account. | see `detail` |
| `404` | The message or session doesn't exist or isn't yours. | — |
| `429` | Too many runs in flight. | `too_many_inflight` |
| `429` | Over the per-minute rate limit. Back off and retry. | — |

## Examples

### Wait for the answer (shell)

Polls every 10 seconds until the run is over, then prints the result. Needs `jq`.

```bash
TOKEN="3f9a7c1e-5b2d-4086-a9e1-c7f2b8d05e64"
URL="https://hackergpt.app/api/v1/messages/48213/"

while true; do
  RESULT=$(curl -s "$URL" -H "Authorization: Anon $TOKEN")
  [ "$(echo "$RESULT" | jq -r .status)" != "pending" ] && break
  sleep 10
done

echo "$RESULT" | jq -r .status     # done or failed
echo "$RESULT" | jq -r .response   # the answer, or the error text
```

### Send and wait (Python)

Needs `requests` (`pip install requests`).

```python
import time
import requests

BASE = "https://hackergpt.app/api/v1"
HEADERS = {"Authorization": "Anon 3f9a7c1e-5b2d-4086-a9e1-c7f2b8d05e64"}

def ask(message, session_id=None, tool=None):
    body = {"message": message}
    if session_id:
        body["session_id"] = session_id
    if tool:
        body["tool"] = tool

    r = requests.post(f"{BASE}/messages/", json=body, headers=HEADERS)
    r.raise_for_status()
    msg = r.json()

    while msg["status"] == "pending":
        time.sleep(10)
        r = requests.get(f"{BASE}/messages/{msg['message_id']}/", headers=HEADERS)
        r.raise_for_status()
        msg = r.json()

    if msg["status"] == "failed":
        raise RuntimeError(msg["response"])
    return msg

first = ask("whois hackergpt.app", tool="osint")
print(first["response"])

follow = ask("what about its SSL config?", session_id=first["session_id"])
print(follow["response"])
```

## Support

[support@hackergpt.app](mailto:support@hackergpt.app). Never email your token: we can't use it to help you, and anyone who reads it can use your account.
