---
title: "Generate a service access token"
method: POST
path: "/api/v2/sandboxes/boxes/{name}/service-url"
tags: ["sandboxes"]
---

# Generate a service access token

`POST /api/v2/sandboxes/boxes/{name}/service-url`

## Request

- Base URL: `https://api.smith.langchain.com`
- URL: `https://api.smith.langchain.com/api/v2/sandboxes/boxes/{name}/service-url`
- Auth: one of:
  - API key in header `X-API-Key`
  - API key in header `X-Tenant-Id`
  - HTTP bearer

Create a short-lived JWT for accessing an HTTP service running on a specific port inside a sandbox. Returns a browser_url (sets auth cookie via redirect), an embed_url (for an iframe; carries the token in the URL fragment, so no server or Referer sees it), a service_url (for use with the X-Langsmith-Sandbox-Service-Token header), the raw token, and its expiry. Set access=restricted|workspace to instead enable durable LangSmith login (no token; users authenticate with their normal LangSmith session), or access=off to disable it. embed_origins names the pages that may show the URL in an iframe. In token mode they are bound into the minted token; with LangSmith login they are stored on the grant and a viewer signs in from inside the frame through a LangSmith popup. LangSmith login and token access are mutually exclusive per service URL.

## Path parameters

- `name` string, required

## Request body

- SandboxesServiceURLPayload
  - `access` 'restricted' | 'workspace' | 'off': Access selects the login mode, mutually exclusive with the minted token. Omit the field for token mode: mint a short-lived service token (default). "restricted" — LangSmith login: the sandbox's creator, or any user with SandboxesExec on it (admins by default). "workspace" — LangSmith login: any member of the owning workspace. "off" — remove an existing LangSmith login grant and mint a token. A LangSmith login grant is durable; token mode is refused (409) while one exists.
  - `embed_origins` string[]: EmbedOrigins are the pages allowed to show the service URL in an iframe, besides LangSmith itself: at most 5 origins such as https://app.example.com (http only for localhost). In token mode they are bound into the minted token, so they last as long as it does. With access "restricted" or "workspace" each call sets the grant's whole list, so omitting the field removes any origins set before.
  - `expires_in_seconds` integer
  - `port` integer

## Response `200`

OK

- SandboxesServiceURLResponse
  - `access` 'restricted' | 'workspace': Access echoes the enabled LangSmith login level ("restricted"/"workspace"); omitted in token mode.
  - `browser_url` string
  - `embed_origins` string[]: EmbedOrigins echoes the origins that may embed the URL, normalized; omitted when there are none.
  - `embed_url` string: EmbedURL opens the service in an iframe: the token rides the URL fragment, which no server, log or Referer header sees, and the page it loads trades it for the cookie. Append &redirect=/path to land elsewhere than /. Omitted in LangSmith login mode.
  - `expires_at` string
  - `service_url` string
  - `token` string: Token and ExpiresAt are empty in LangSmith login mode (no token is minted).

## Other responses

- `400`: Bad Request
- `404`: Not Found
- `409`: Conflict
- `422`: Unprocessable Entity
- `500`: Internal Server Error
- `501`: Not Implemented

## Changes

- **2026-10-26** `dfe647d1748e`: 1 info
  - added the optional property `embed_url` to the response with the `200` status
- **2026-10-21** `016683c2a6e3`: 2 info
  - added the new optional request property `embed_origins`
  - added the optional property `embed_origins` to the response with the `200` status
- **2026-10-16** `1a8ee9358d81`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/langchain-ai/apis/langsmith/changes/api/v2/sandboxes/boxes/:name/service-url/post.md)

---

[API](https://skmtc.dev/langchain-ai/apis/langsmith.md) - [All operations](https://skmtc.dev/langchain-ai/apis/langsmith/llms.txt) - [OpenAPI document](https://skmtc.dev/langchain-ai/apis/langsmith/revisions/7a01c01f75e8?raw)
