# HTTP API

> POST /solve fields, cookies, named sessions and errors for the local Nullgate HTTP API.

The base URL is `http://127.0.0.1:8191`. [Start the server](https://nullgate.club/en/start), then call it with any HTTP client. Local requests need no authorization: the key belongs to the server process.

## POST /solve

Send JSON with `Content-Type: application/json`. A new visit needs `type`, `url` and `user_agent`.

| Field | Value |
| --- | --- |
| `type` | `akamai`, `threatmetrix`, `pingone` or `amazon_acic` |
| `url` | Absolute HTTP(S) target page URL, without credentials or a `#` fragment |
| `user_agent` | Your client's user agent. A normal browser's user agent is accepted |
| `proxy` | Proxy for target requests. Without one, the connection is direct |
| `session` | Optional visit name, up to 128 characters |
| `cookies` | Your client's current cookie array |
| `html` | HTML you already fetched. The server skips fetching that page again |
| `script_url` | Actual script URL when discovery from HTML fails. Not used for `amazon_acic` |
| `headers` | Additional headers for target requests |
| `pixel_iframe` | Akamai only: `true` for Pixel in a hidden iframe |
| `collector` | ThreatMetrix only: the site's `url`, `org_id` and `session_id` object |
| `pingone` | PingOne only: additional profile options |
| `transport` | TLS, HTTP/2 and header-order settings. See [Deep](https://nullgate.club/en/deep#transport) |

`html` does not disable script downloads or later requests in the flow. Keep the user agent and proxy consistent with your target client.

## Response

HTTP 200 returns an object with `cookies` and `result`.

| Type | `result` fields |
| --- | --- |
| `akamai` | `accepted: true` when `_abck` reports acceptance |
| `threatmetrix` | `collected: true` after collection and pagehide |
| `pingone` | `data`, `device_id`, `sdk_version`, `request_id`. You perform the application login |
| `amazon_acic` | `status: "PASS"`, final `url` and `status_code` |

`cookies` is an array of objects with `name`, `value`, `domain`, `path`, `secure`, `http_only`, `expires`, `host_only` and `same_site`. Restore all attributes in your client's cookie jar. Do not combine cookies from different domains in one header.

For PingOne, include `result.data` in the application's normal request. Cookies alone do not replace it.

## Sessions and cookies

The first call with a new `session` creates a visit. The server retains cookies and pins the user agent, proxy and transport. Later calls can omit those settings. Use a new session name to change them.

If your client updates cookies, send its current array in the next request. It replaces stored cookies for the origin of `url`. An empty array clears that snapshot. Omitting the field keeps the server's cookies.

The local `session` name does not replace the site's ThreatMetrix `collector.session_id`.

Sessions live in memory. Create the visit again after restarting the server. Without a name, a session lasts for one solve only.

## PingOne

The `pingone` object accepts `sdk_config`, `jwt_device_attributes`, `jwt_agent_payload`, `client_token`, `token_host` and `behavioral`.

If you already have `client_token`, the server uses it. Otherwise it fetches the token through your proxy. Supply `script_url` when the SDK loads dynamically and its URL is absent from the HTML.

Signed inputs and device identity: [PingOne SDK](https://nullgate.club/en/pingone).

## Errors

An error contains `code`, `message`, `stage` and `request_id`. Optional `cause` can identify the transport failure type. Keep `request_id` when contacting support.

| HTTP | Code | Action |
| --- | --- | --- |
| 400 | `invalid_request` | Fix the request fields |
| 409 | `session_conflict`, `session_not_found` | Check the session name and pinned settings |
| 429 | `busy`, `session_capacity` | Reduce concurrent solves |
| 502 | `target_error`, `transport_error`, `solve_failed`, `protection_not_found` | Check `stage`, the page, proxy and script URL |
| 504 | `timeout` | Check target availability and execution time |

Other generation errors can come from the [Nullgate API](https://nullgate.club/en/errors). Do not automatically retry paid `/solve` calls: some generations may already have completed and been charged.

## Server options

| Setting | Default |
| --- | --- |
| `--port` | `8191` |
| `--timeout` | `60` seconds, maximum `180` |
| `--base-url` | `https://api.nullgate.club`, the generation API URL |
| `NULLGATE_API_KEY` | If absent, the server asks for it at a hidden prompt |

`GET /health` returns `{"status":"ok"}`. JSON bodies may contain up to 8 MiB.

The server binds only to IPv4 loopback, checks `Host` and `Origin` and does not enable CORS. Call it from your application, not another website's JavaScript. Do not publish the port or grant untrusted local users access.
