Docs / API: Keys
Create an API key
Creates a key and returns it once. Needs a session. An account can hold 5 active keys.
POST/api/v1/keys
| Property | Value |
|---|---|
| Authentication | Needs a wallet session. Sign in at the console. |
| Rate-limit cost | 0 units |
| Status | Live |
#Request body
JSON
{
"label": "my-app"
}#Request
curl -s -X POST "https://farbeamlabs.com/api/v1/keys" \
-H "content-type: application/json" \
-d '{"label": "my-app"}'const res = await fetch("https://farbeamlabs.com/api/v1/keys", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({"label": "my-app"})
});
const { data, meta, error } = await res.json();
if (error) throw new Error(`${error.code}: ${error.message}`);
console.log(data);import os, requests
res = requests.post(
"https://farbeamlabs.com/api/v1/keys",
json={'label': 'my-app'},
timeout=30,
)
body = res.json()
if "error" in body:
raise RuntimeError(body["error"]["code"])
print(body["data"])#Notes
- Farbeam stores only a SHA-256 hash of the key. A lost key cannot be recovered, so save it when it is shown.
#Errors
| HTTP | Code | Meaning |
|---|---|---|
| 401 | sign_in_required | Sign in with a wallet first. |
| 409 | key_limit | The account holds 5 active keys. |
All errors share one format. See errors.