鍵
Tokens API
3 operationstokens:admin
Scoped API tokens with expiry, IP allowlists and rate limits. A token can mint narrower tokens for your own customers.
| GET | /tokens | List the API tokens of the account. |
| POST | /tokens | Create a token with a subset of the caller's scopes. The secret is returned once. |
| DELETE | /tokens/{tokenId} | Delete a token. |
List the API tokens of the account.
GET
/v1/tokensscope tokens:admin
Parameters
pageinteger | |
limitinteger | |
withTotalboolean |
Response
19 fields
pageOptions | PageResult | null |
hasNext | boolean |
page | integer (int32) |
total | integer (int64) |
results | ApiToken[] |
allowIps | string[] |
createdAt | integer (int64) |
creditLimit | integer (int64) | null |
expiresAt | integer (int64) | null |
lastUsedAt | integer (int64) | null |
name | string |
oauthClient | string | null |
prefix | string |
rateLimitRpm | integer (int32) |
revokedAt | integer (int64) | null |
scopes | string[] |
tokenId | string |
unitsUsed | integer (int64) |
updatedAt | integer (int64) |
curl "https://api.hoshime.com/v1/tokens" \ -H "Authorization: Bearer $HOSHIME_TOKEN"
const res = await fetch("https://api.hoshime.com/v1/tokens", { headers: { Authorization: `Bearer ${process.env.HOSHIME_TOKEN}`, }, }); const { data, meta } = await res.json();
import os, requests res = requests.get( "https://api.hoshime.com/v1/tokens", headers={"Authorization": f"Bearer {os.environ['HOSHIME_TOKEN']}"}, ) body = res.json()
{ "pageOptions": { "hasNext": false, "page": 0, "total": 0 }, "results": [ { "allowIps": [ "…" ], "createdAt": 0, "creditLimit": null, "expiresAt": null, "lastUsedAt": null, "name": "…", "oauthClient": null, "prefix": "…", "rateLimitRpm": 0, "revokedAt": null, "scopes": [ "…" ], "tokenId": "abc123", "unitsUsed": 0, "updatedAt": 0 } ] }
Create a token with a subset of the caller's scopes. The secret is returned once.
POST
/v1/tokensscope tokens:admin
Request body
allowIpsstring[] | |
expiresAtinteger (int64) | null | |
namestring required | |
rateLimitRpminteger (int32) | null | |
scopesstring[] required |
Response
16 fields
secret | string |
token | ApiToken | null |
allowIps | string[] |
createdAt | integer (int64) |
creditLimit | integer (int64) | null |
expiresAt | integer (int64) | null |
lastUsedAt | integer (int64) | null |
name | string |
oauthClient | string | null |
prefix | string |
rateLimitRpm | integer (int32) |
revokedAt | integer (int64) | null |
scopes | string[] |
tokenId | string |
unitsUsed | integer (int64) |
updatedAt | integer (int64) |
curl -X POST "https://api.hoshime.com/v1/tokens" \ -H "Authorization: Bearer $HOSHIME_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "allowIps": [ "…" ], "expiresAt": 0, "name": "…", "rateLimitRpm": 0, "scopes": [ "…" ] }'
const res = await fetch("https://api.hoshime.com/v1/tokens", { method: "POST", headers: { Authorization: `Bearer ${process.env.HOSHIME_TOKEN}`, "Content-Type": "application/json", }, body: JSON.stringify({ "allowIps": [ "…" ], "expiresAt": 0, "name": "…", "rateLimitRpm": 0, "scopes": [ "…" ] }), }); const { data, meta } = await res.json();
import os, requests res = requests.post( "https://api.hoshime.com/v1/tokens", headers={"Authorization": f"Bearer {os.environ['HOSHIME_TOKEN']}"}, json={ "allowIps": [ "…" ], "expiresAt": 0, "name": "…", "rateLimitRpm": 0, "scopes": [ "…" ] }, ) body = res.json()
{ "secret": "…", "token": { "allowIps": [ "…" ], "createdAt": 0, "creditLimit": 0, "expiresAt": 0, "lastUsedAt": 0, "name": "…", "oauthClient": "…", "prefix": "…", "rateLimitRpm": 0, "revokedAt": 0, "scopes": [ "…" ], "tokenId": "abc123", "unitsUsed": 0, "updatedAt": 0 } }
Delete a token.
DELETE
/v1/tokens/{tokenId}scope tokens:admin
Parameters
tokenIdstring · path required |
Response
1 fields
status | boolean |
curl -X DELETE "https://api.hoshime.com/v1/tokens/{tokenId}" \ -H "Authorization: Bearer $HOSHIME_TOKEN"
const res = await fetch("https://api.hoshime.com/v1/tokens/{tokenId}", { method: "DELETE", headers: { Authorization: `Bearer ${process.env.HOSHIME_TOKEN}`, }, }); const { data, meta } = await res.json();
import os, requests res = requests.delete( "https://api.hoshime.com/v1/tokens/{tokenId}", headers={"Authorization": f"Bearer {os.environ['HOSHIME_TOKEN']}"}, ) body = res.json()
{ "status": false }