Skip to content

Getting Started

The Smartplan API uses OAuth2 authentication.

You need to use the client_id and client_secret from the the API settings within the Smartplan app.

client_id and client_secret are then used to retrieve an access_token - which is used for each API request.

access_tokens are valid for 10 minutes after which you have to retrieve a new one.

To retrieve an access token you need to make a POST request to this url: https://api.smartplanapp.io/o/token/

The body should contain the following:

  • grant_type= client_credentials
  • client_secret=<YOUR CLIENT SECRET>
  • client_id=<YOUR CLIENT ID>

You also need to make sure the headers content-type is set to application/x-www-form-urlencoded

Example: Retrieving Access-Token (python3.7):

    import requests
    client_id = "YOUR CLIENT ID"
    client_secret = "YOUR CLIENT SECRET"
    payload = "grant_type=client_credentials&client_secret={0}&client_id={1}".format(client_secret, client_id)
    headers = {
        'content-type': "application/x-www-form-urlencoded",
        'cache-control': "no-cache",
    }
    url = "https://api.smartplanapp.io/o/token/"
    response = requests.request("POST", url, data=payload, headers=headers)
    access_token = response.json()['access_token']

Example: Using Access-Token to retrieve Account information (python3.7):

    import requests
    url = "https://api.smartplanapp.io/v2/accounts/"
    headers = {
        'content-type': "application/json",
        'Authorization': "Bearer {0}".format(access_token),
    }
    response = requests.get(url, headers=headers)

response = {
    'total_count': 1,
    'results': [{
      'uuid': '<Account UUID>',
      'name': 'Test Account1', 
      'timezone': 'Europe/Copenhagen', 
      'country': 'DK', 
      'clock_format': '24', 
      'week_numbers': True, 
      'pref_language': 'da'}
  ]
}

save the account UUID for later; It's required as part of the various endpoints.