> For the complete documentation index, see [llms.txt](https://docs.opinion.trade/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.opinion.trade/developer-guide/opinion-open-api/auth.md).

# Auth

Self-service API key management (create / retrieve / delete), authenticated by an EIP-712 wallet signature instead of an API key. See the Authentication section for the typed-data structure, examples, error codes and activation timing.

## Get API key

> Retrieve the wallet's current API key. Authenticated by an EIP-712 wallet signature with \`action: get\` (see the Authentication section).\
> \
> Returns HTTP 200 with the outcome in \`errno\`: \`0\` success, \`11010\` no API key found, \`11011\` / \`11012\` invalid / expired signature. \`get\` signatures can be retried within the 5-minute window.<br>

```json
{"openapi":"3.0.3","info":{"title":"OPINION Prediction Market OpenAPI","version":"1.0.0"},"tags":[{"name":"Auth","description":"Self-service API key management (create / retrieve / delete), authenticated by an EIP-712 wallet signature instead of an API key. See the Authentication section for the typed-data structure, examples, error codes and activation timing."}],"servers":[{"url":"https://openapi.opinion.trade/openapi","description":"Production server"}],"security":[],"paths":{"/auth/api-key":{"get":{"tags":["Auth"],"summary":"Get API key","description":"Retrieve the wallet's current API key. Authenticated by an EIP-712 wallet signature with `action: get` (see the Authentication section).\n\nReturns HTTP 200 with the outcome in `errno`: `0` success, `11010` no API key found, `11011` / `11012` invalid / expired signature. `get` signatures can be retried within the 5-minute window.\n","operationId":"getApiKey","parameters":[{"$ref":"#/components/parameters/OpinionAddressHeader"},{"$ref":"#/components/parameters/OpinionSignatureHeader"},{"$ref":"#/components/parameters/OpinionTimestampHeader"}],"responses":{"200":{"description":"Successful response (check `errno` in the body)","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/AuthAPIBaseResponse"},{"type":"object","properties":{"result":{"$ref":"#/components/schemas/ApiKeyCredential"}}}]}}}}}}}},"components":{"parameters":{"OpinionAddressHeader":{"name":"OPINION_ADDRESS","in":"header","required":true,"description":"Signing wallet address","schema":{"type":"string"}},"OpinionSignatureHeader":{"name":"OPINION_SIGNATURE","in":"header","required":true,"description":"EIP-712 signature over the `OpinionApiKeyAuth` typed data (see the Authentication section)","schema":{"type":"string"}},"OpinionTimestampHeader":{"name":"OPINION_TIMESTAMP","in":"header","required":true,"description":"Unix timestamp in seconds; must equal the signed `timestamp` field. Valid for 5 minutes.","schema":{"type":"string"}}},"schemas":{"AuthAPIBaseResponse":{"type":"object","description":"Envelope used by the Auth endpoints. Unlike the data endpoints, the outcome is reported in `errno` / `errmsg`.","properties":{"errno":{"type":"integer","description":"Business result code (0 for success; see the Authentication section for the full list)"},"errmsg":{"type":"string","description":"Error message (empty on success)"},"result":{"type":"object","description":"Response data"}}},"ApiKeyCredential":{"type":"object","properties":{"apiKey":{"type":"string","description":"The API key for the `apikey` request header"},"walletAddress":{"type":"string","description":"Wallet address the key belongs to"}}}}}}
```

## Create API key

> Create the wallet's API key. Authenticated by an EIP-712 wallet signature with \`action: create\` (see the Authentication section).\
> \
> Returns HTTP 200 with the outcome in \`errno\`: \`0\` success, \`11004\` issuance disabled, \`11005\` wallet is not a registered Opinion account, \`11009\` key already exists, \`11011\` / \`11012\` / \`11013\` invalid / expired / already-used signature. A newly created key becomes active at the gateway within about 15 seconds — retry on \`401\`.<br>

```json
{"openapi":"3.0.3","info":{"title":"OPINION Prediction Market OpenAPI","version":"1.0.0"},"tags":[{"name":"Auth","description":"Self-service API key management (create / retrieve / delete), authenticated by an EIP-712 wallet signature instead of an API key. See the Authentication section for the typed-data structure, examples, error codes and activation timing."}],"servers":[{"url":"https://openapi.opinion.trade/openapi","description":"Production server"}],"security":[],"paths":{"/auth/api-key":{"post":{"tags":["Auth"],"summary":"Create API key","description":"Create the wallet's API key. Authenticated by an EIP-712 wallet signature with `action: create` (see the Authentication section).\n\nReturns HTTP 200 with the outcome in `errno`: `0` success, `11004` issuance disabled, `11005` wallet is not a registered Opinion account, `11009` key already exists, `11011` / `11012` / `11013` invalid / expired / already-used signature. A newly created key becomes active at the gateway within about 15 seconds — retry on `401`.\n","operationId":"createApiKey","parameters":[{"$ref":"#/components/parameters/OpinionAddressHeader"},{"$ref":"#/components/parameters/OpinionSignatureHeader"},{"$ref":"#/components/parameters/OpinionTimestampHeader"}],"responses":{"200":{"description":"Successful response (check `errno` in the body)","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/AuthAPIBaseResponse"},{"type":"object","properties":{"result":{"$ref":"#/components/schemas/ApiKeyCredential"}}}]}}}}}}}},"components":{"parameters":{"OpinionAddressHeader":{"name":"OPINION_ADDRESS","in":"header","required":true,"description":"Signing wallet address","schema":{"type":"string"}},"OpinionSignatureHeader":{"name":"OPINION_SIGNATURE","in":"header","required":true,"description":"EIP-712 signature over the `OpinionApiKeyAuth` typed data (see the Authentication section)","schema":{"type":"string"}},"OpinionTimestampHeader":{"name":"OPINION_TIMESTAMP","in":"header","required":true,"description":"Unix timestamp in seconds; must equal the signed `timestamp` field. Valid for 5 minutes.","schema":{"type":"string"}}},"schemas":{"AuthAPIBaseResponse":{"type":"object","description":"Envelope used by the Auth endpoints. Unlike the data endpoints, the outcome is reported in `errno` / `errmsg`.","properties":{"errno":{"type":"integer","description":"Business result code (0 for success; see the Authentication section for the full list)"},"errmsg":{"type":"string","description":"Error message (empty on success)"},"result":{"type":"object","description":"Response data"}}},"ApiKeyCredential":{"type":"object","properties":{"apiKey":{"type":"string","description":"The API key for the `apikey` request header"},"walletAddress":{"type":"string","description":"Wallet address the key belongs to"}}}}}}
```

## Delete API key

> Delete (revoke) the wallet's current API key. Authenticated by an EIP-712 wallet signature with \`action: delete\` (see the Authentication section). Deleting when no key exists is treated as success, so it is safe to retry.\
> \
> The revoked key stops working at the gateway within about 10 seconds.<br>

```json
{"openapi":"3.0.3","info":{"title":"OPINION Prediction Market OpenAPI","version":"1.0.0"},"tags":[{"name":"Auth","description":"Self-service API key management (create / retrieve / delete), authenticated by an EIP-712 wallet signature instead of an API key. See the Authentication section for the typed-data structure, examples, error codes and activation timing."}],"servers":[{"url":"https://openapi.opinion.trade/openapi","description":"Production server"}],"security":[],"paths":{"/auth/api-key":{"delete":{"tags":["Auth"],"summary":"Delete API key","description":"Delete (revoke) the wallet's current API key. Authenticated by an EIP-712 wallet signature with `action: delete` (see the Authentication section). Deleting when no key exists is treated as success, so it is safe to retry.\n\nThe revoked key stops working at the gateway within about 10 seconds.\n","operationId":"deleteApiKey","parameters":[{"$ref":"#/components/parameters/OpinionAddressHeader"},{"$ref":"#/components/parameters/OpinionSignatureHeader"},{"$ref":"#/components/parameters/OpinionTimestampHeader"}],"responses":{"200":{"description":"Successful response (check `errno` in the body)","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/AuthAPIBaseResponse"},{"type":"object","properties":{"result":{"$ref":"#/components/schemas/DeleteApiKeyResult"}}}]}}}}}}}},"components":{"parameters":{"OpinionAddressHeader":{"name":"OPINION_ADDRESS","in":"header","required":true,"description":"Signing wallet address","schema":{"type":"string"}},"OpinionSignatureHeader":{"name":"OPINION_SIGNATURE","in":"header","required":true,"description":"EIP-712 signature over the `OpinionApiKeyAuth` typed data (see the Authentication section)","schema":{"type":"string"}},"OpinionTimestampHeader":{"name":"OPINION_TIMESTAMP","in":"header","required":true,"description":"Unix timestamp in seconds; must equal the signed `timestamp` field. Valid for 5 minutes.","schema":{"type":"string"}}},"schemas":{"AuthAPIBaseResponse":{"type":"object","description":"Envelope used by the Auth endpoints. Unlike the data endpoints, the outcome is reported in `errno` / `errmsg`.","properties":{"errno":{"type":"integer","description":"Business result code (0 for success; see the Authentication section for the full list)"},"errmsg":{"type":"string","description":"Error message (empty on success)"},"result":{"type":"object","description":"Response data"}}},"DeleteApiKeyResult":{"type":"object","properties":{"deleted":{"type":"boolean"}}}}}}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.opinion.trade/developer-guide/opinion-open-api/auth.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
