Refresh an access token

POST https://api.zenoti.com/v1/tokens

Purpose: Use this API to refresh an expired access token. Since an access token is valid for 24 hours, you must use this API to generate a new access token.

###Things to remember:

  • A newly generated refresh token is valid for 90 days (3 months). It will expire after this period.
  • A refresh token can only be used once. Caution: Invoking this API will deactivate the existing access tokens and generate a new access token. So use the Refresh an access token API only when an access token is about to expire or has already expired.

Note: Remove the hash (#) at the end, when using this API.

Before you begin

Permission: Manage API Keys (on the Administrator security object) — Required to access Zenoti APIs.

Endpoint

POST /v1/tokens

Base URL: https://api.zenoti.com

Request

Headers

Header Required Description
Authorization Yes bearer {{access_token}}

Request body

Field Type Required Description
refresh_token string Yes Enter the refresh token that is provided to you when you generate an access token.
grant_type string Yes The grant type will be the refresh token. Enter refresh_token here.

Response

Success (201 Created)

{}

Example

curl --request POST \
  --url 'https://api.zenoti.com/v1/tokens' \
  --header 'Authorization: bearer {{access_token}}' \
  --header 'Content-Type: application/json' \
  --data '{
  "refresh_token": "string",
  "grant_type": "string"
}'
const response = await fetch('https://api.zenoti.com/v1/tokens', {
  method: 'POST',
  headers: {
    'Authorization': 'bearer {{access_token}}',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({ refresh_token: 'string', grant_type: 'string' })
});
const data = await response.json();
import requests

response = requests.post(
    'https://api.zenoti.com/v1/tokens',
    headers={
        'Authorization': 'bearer {{access_token}}',
    },
    json={'refresh_token': 'string', 'grant_type': 'string'}
)
data = response.json()
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", "bearer {{access_token}}");
var content = new StringContent(
    JsonSerializer.Serialize(new { refresh_token = "string", grant_type = "string" }),
    Encoding.UTF8, "application/json");
var response = await client.PostAsync(
    "https://api.zenoti.com/v1/tokens", content);
var data = await response.Content.ReadAsStringAsync();
require 'net/http'
require 'json'

uri = URI('https://api.zenoti.com/v1/tokens')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri)
request['Authorization'] = 'bearer {{access_token}}'
request['Content-Type'] = 'application/json'
request.body = { refresh_token: 'string', grant_type: 'string' }.to_json
response = http.request(request)
data = JSON.parse(response.body)

Error codes

Status Description
400 400
401 Unauthorized -- invalid or expired access token
429 Too many requests -- rate limit exceeded