Create user token
Provides a mechanism for having Surge create a signed token for embeds instead of signing with your own signing key.
Authorization
authorization AuthorizationBearer <token>
In: header
Path Parameters
user_id*string
The user for which the token represents authentication.
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
application/json
import Surge from '@surgeapi/node';
const client = new Surge({
apiKey: process.env['SURGE_API_KEY'], // This is the default and can be omitted
});
const userTokenResponse = await client.users.createToken('usr_01jymgdfrpec2asc5m0z3a6fr9');
console.log(userTokenResponse.token);{
"token": "eyJhbGciOiJFZERTQSIsImtpZCI6InNnbl8wMWp5bWowZ3AwZjNidmJmMmpyazRoYnd0ayIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3NTA4ODkyMDgsInN1YiI6InVzcl8wMWp5bWdkZnJwZWMyYXNjNW0wejNhNmZyOSJ9.zKayo3EDrUm1Hw8URrofuYwajgyTu6dH2H0FEuRExprP1IV66FHa8wC3SfdzV7sR3AjDGAwkuAXztScq6rBnBw"
}{
"error": {
"message": "The requested resource could not be found.",
"type": "not_found"
}
}