Generate a new token for your account.
Parameter | Type | Required | Description |
---|---|---|---|
type | string | The type of the token, which can be used to classify tokens for different purposes. | |
refId | string | A reference identifier for the token, which can be used to associate the token with a specific entity, such as a user. | |
payload | string | obj | The payload of the token, which can be a string or an object. This can be used to store additional information related to the token, such as user details or permissions. | |
uses | number | The number of times the token has been used. This is not usually set when creating a token. This value is auto-incremented when the token is redeemed. | |
maxUses | number | The maximum number of times the token can be used before it becomes invalid. | |
expiresAt | Date | The date and time when the token expires. After this time, the token is no longer valid. |
import axios from 'axios';
const props = {
type: 'session',
refId: 'some-object-id',
payload: {hello: 'world'},
uses: 0,
maxUses: 10,
expiresAt: new Date('2050-01-01')
}
const config = {headers: {authorization: API_KEY_ID}}
let {status, data} = await axios.post(
'https://api.x-tkn.com/tokens/create',
props,
config
)
let token = data
Permanently delete token from your account.
Parameter | Type | Required | Description |
---|---|---|---|
tokenId | string | The unique identifier of the token to be deleted |
import axios from 'axios';
const tokenId = 'some-token-id'
const config = {headers: {authorization: API_KEY_ID}}
await axios.delete(
'https://api.x-tkn.com/tokens/' + tokenId,
config
)
Extends the expiration date of a token by the given amount of time.
Parameter | Type | Required | Description |
---|---|---|---|
where | object | The unique identifier of the token to be deleted | |
orderBy | object | The order in which the tokens are returned. Default: {createdAt: 'desc'}. | |
skip | number | The number of tokens to skip before returning the first token. Default: 0. | |
take | number | The number of tokens to return. Default: 100. |
import axios from 'axios';
const req = {
where: {
refId: 'some-object-id',
type: 'session'
},
orderBy: {createdAt: 'desc'},
skip: 0,
take: 100
}
const config = {headers: {authorization: API_KEY_ID}}
const {count, tokens} = await axios.post(
'https://api.x-tkn.com/tokens/list',
req,
config
)
This method returns a token object for the specified token id.
Parameter | Type | Required | Description |
---|---|---|---|
tokenId | string | The unique identifier of the token to be deleted |
import axios from 'axios';
const tokenId = 'some-token-id'
const config = {headers: {authorization: API_KEY_ID}}
const token = await axios.get(
'https://api.x-tkn.com/tokens/' + tokenId,
config
)
This method returns a token object for the specified token id or short code. It is primarily used for limited use tokens. Calling this method will increment the token's use count.
Parameter | Type | Required | Description |
---|---|---|---|
tokenId or shortCode | string | The unique identifier of the token to be redeemed. |
import axios from 'axios';
const tokenId = 'some-token-id--or--short-code'
const config = {headers: {authorization: API_KEY_ID}}
const token = await axios.patch(
'https://api.x-tkn.com/tokens/' + tokenId + '/redeem',
data,
config
)
This method revokes the specified token. A revoked token will no longer be valid.
Parameter | Type | Required | Description |
---|---|---|---|
tokenId | string | The unique identifier of the token to be deleted |
import axios from 'axios';
const tokenId = 'some-token-id'
const config = {headers: {authorization: API_KEY_ID}}
const token = await axios.patch(
'https://api.x-tkn.com/tokens/' + tokenId + '/revoke',
config
)
Revokes many tokens that match the specified type or refId
Parameter | Type | Required | Description |
---|---|---|---|
type | string | The type of the token, which can be used to classify tokens for different purposes. | |
refId | string | A reference identifier for the token, which can be used to associate the token with a specific entity, such as a user. |
import axios from 'axios';
const data = {
refId: 'some-token-id',
type: 'some-type'
}
const config = {headers: {authorization: API_KEY_ID}}
const token = await axios.post(
'https://api.x-tkn.com/tokens/revoke',
data,
config
)
This method updates the specified token. The following properties can be updated: type, refId, payload, uses, maxUses and expiresAt
Parameter | Type | Required | Description |
---|---|---|---|
type | string | The type of the token, which can be used to classify tokens for different purposes. | |
refId | string | A reference identifier for the token, which can be used to associate the token with a specific entity, such as a user. | |
payload | string | obj | The payload of the token, which can be a string or an object. This can be used to store additional information related to the token, such as user details or permissions. | |
uses | number | The number of times the token has been used. This is not usually set when creating a token. This value is auto-incremented when the token is redeemed. | |
maxUses | number | The maximum number of times the token can be used before it becomes invalid. | |
expiresAt | Date | The date and time when the token expires. After this time, the token is no longer valid. |
import axios from 'axios';
const tokenId = 'some-token-id'
const config = {headers: {authorization: API_KEY_ID}}
const token = await axios.patch(
'https://api.x-tkn.com/tokens/' + tokenId + '/revoke',
config
)