---
title: "Create JWT tokens to start and fetch a preview using the data plane API."
method: POST
path: "/preview/tokens"
tags: ["Data Plane Tokens"]
---

# Create JWT tokens to start and fetch a preview using the data plane API.

`POST /preview/tokens`

## Request

- Base URL: `https://replace-with-account.api.decodable.co/v1alpha2`
- URL: `https://replace-with-account.api.decodable.co/v1alpha2/preview/tokens`
- Auth: HTTP bearer
- TypeScript: <https://skmtc.dev/decodable/apis/decodable-control-plane/docs/preview/tokens/post.ts> (a function with typed inputs; its response is checked against the schema)

Requires permission matching: `preview:write:default.<name>`, where `name` is that of _each_ stream referenced as input in the given `sql`.

## Request body

- object
  - `sql` string, required: The sql to execute as a preview.
  - `start_positions` object

## Response `200`

A request and token issued by the control plane API for use with the data plane API.

- object
  - `post_token` string, required: A JWT token issued by the control plane API permitting a specific request to the data plane.
  - `get_token` string, required: A JWT token issued by the control plane API permitting a specific request to the data plane.
  - `data_plane_request` string, required: A stringified json request body for the data plane API which is permitted and signed by the associated JWT token. It must be sent verbatim (including whitespace) in order to match the token signature.

## Other responses

- `400`: An invalid request was received.
- `403`: Access denied: requesting user lacks a required permission.
- `default`: An error has occurred.

---

[API](https://skmtc.dev/decodable/apis/decodable-control-plane.md) - [All operations](https://skmtc.dev/decodable/apis/decodable-control-plane/llms.txt) - [OpenAPI document](https://skmtc.dev/decodable/apis/decodable-control-plane/revisions/9718a3019da8?raw)
