POST
/
users
/
{user_id}
/
tokens
JavaScript
import Surge from '@surgeapi/node';

const client = new Surge({
  apiKey: 'My API Key',
});

const userTokenResponse = await client.users.createToken('usr_01jymgdfrpec2asc5m0z3a6fr9');

console.log(userTokenResponse.token);
{
  "token": "eyJhbGciOiJFZERTQSIsImtpZCI6InNnbl8wMWp5bWowZ3AwZjNidmJmMmpyazRoYnd0ayIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3NTA4ODkyMDgsInN1YiI6InVzcl8wMWp5bWdkZnJwZWMyYXNjNW0wejNhNmZyOSJ9.zKayo3EDrUm1Hw8URrofuYwajgyTu6dH2H0FEuRExprP1IV66FHa8wC3SfdzV7sR3AjDGAwkuAXztScq6rBnBw"
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Path Parameters

user_id
string
required

The user for which the token represents authentication.

Example:

"usr_01jymgdfrpec2asc5m0z3a6fr9"

Body

application/json

A request to create a token

duration_seconds
integer

For how many seconds the token should be accepted. Defaults to 15 minutes.

Required range: 15 <= x <= 3600
Example:

900

Response

Created token

Response when token has been created successfully

token
string

The created token.