---
title: "Mint a token for a service of a rig on your own host"
method: POST
path: "/api/v0beta1/sandboxes/{id}/services/{ref}/tokens"
tags: ["Sandboxes"]
---

# Mint a token for a service of a rig on your own host

`POST /api/v0beta1/sandboxes/{id}/services/{ref}/tokens`

## Request

- Base URL: `https://app.amika.dev` (the document declares no server; this is the origin it was published from)
- URL: `https://app.amika.dev/api/v0beta1/sandboxes/{id}/services/{ref}/tokens`
- Auth: one of:
  - HTTP bearer
  - API key in cookie `wos-session`

For callers that are not browsers, such as `curl` or a script: send the token in the returned `header` as `Bearer <token>` to the returned `url`. Only for rigs on the organization's own hosts; never for `amikad`.

## Path parameters

- `id` string, required
- `ref` string, required: Service reference: its name (default) or row id. Use `by` to choose.

## Query parameters

- `sandbox_by` 'name' | 'id' | 'ref' | 'name_or_id': How to interpret the sandbox `{id}` path param: ref/name_or_id (default; matches an id or a name and rejects an ambiguous match with 409 `resource_ref_ambiguous`), name, or id.
- `by` 'name' | 'id' | 'ref' | 'name_or_id': How to interpret the service `{ref}`: name (default), id, or ref/name_or_id (matches either; rejects ambiguity).
- `ttl_seconds` integer: How long the token lives, in seconds: 1 to 86400. Defaults to an hour.

## Response `201`

Token minted.

- SandboxServiceToken
  - `url` string, required: The service's address on the rig's host, ending in `/`. It carries no credential.
  - `header` string, required: The request header the token goes in, as `Bearer <token>`.
  - `token` string, required
  - `expires_at` union, required
    - string
    - string, date-time

## Other responses

- `400`: Error
- `401`: Error
- `403`: Error
- `404`: Error
- `409`: Error
- `503`: Error

## Changes

- **2026-10-16** `d141c3e79526`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/amika/apis/amika-api/changes/api/v0beta1/sandboxes/:id/services/:ref/tokens/post.md)

---

[API](https://skmtc.dev/amika/apis/amika-api.md) - [All operations](https://skmtc.dev/amika/apis/amika-api/llms.txt) - [OpenAPI document](https://skmtc.dev/amika/apis/amika-api/revisions/86f031a957c1?raw)
