AccessToken

Access Tokens play a crucial role in authentication for the majority of API calls.

While you can create an access token for your primary account, the API also supports generating access tokens for sub-accounts. This allows specific users to log in and access particular Organizations, resources, and scopes, enabling you to fine-tune access control.

By generating access tokens for sub-accounts, you can maintain centralized oversight of multiple Organizations and delegate tasks to sub-account users. This ensures they only access the data they need, streamlining the management process and enhancing security.

Endpoints:

  • POST /v1/Accounts/:id/accessTokens
  • GET /v1/Accounts/:id/accessTokens
  • DELETE /v1/Accounts/:id/accessTokens/:fk

The AccessToken object

Parameters

  • id string readonly

  • ttl number

    time to live in seconds (2 weeks by default)

  • Additional propertiesExpand all
    
      {
  "id": "XZHx7ODN0cq2bCDhdbLHD4CK0dR0uXTmNCuZqCSYxqQWCkRs7YiTCLa2s2zsWKAb",
  "ttl": 1209600,
  "scopes": [
    "string"
  ],
  "created": "2022-04-20T10:10:30+00:00Z",
  "userId": "string"
}    
  

Create AccessToken

POST /v1/Accounts/:id/accessTokens

Parameters

Path
  • id string required

    Account id

Properties

  • ttl number optional

    Default is: 1209600

    time to live in seconds (2 weeks by default)

  • Additional propertiesExpand all
      
        const response = await fetch('https://api.spaceinvoices.com/v1/Accounts/{id}/accessTokens', {
  method: 'POST',
  headers: {
    'Authorization': 'ACCESS_TOKEN',
    'content-type': 'application/json'
  },
  body: JSON.stringify({
    ttl: 1209600,
    scopes: ['string']
  })
});      
    

Your access token is displayed in examples.

Prerequisite: npm install node-fetch

        
          curl -X POST https://api.spaceinvoices.com/v1/Accounts/{id}/accessTokens \
  -H 'Authorization: ACCESS_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
    "ttl": 1209600, \
    "scopes": ["string"]
  }'        
      

Your access token displayed in examples.

        
          import requests
url = 'https://api.spaceinvoices.com/v1/Accounts/{id}/accessTokens'
headers = {
  'Authorization': 'ACCESS_TOKEN',
  'content-type': 'application/json',
}
params = {
  'ttl': 1209600,
  'scopes': ['string']
}
response = requests.post(url, json=params, headers=headers)        
      

Your access token displayed in examples.

Response:

    
      {
  "id": "string",
  "ttl": 1209600,
  "scopes": ["string"],
  "created": "2022-04-20T10:10:30+00:00Z",
  "userId": "string"
}    
  

Find AccessTokens

GET /v1/Accounts/:id/accessTokens

Parameters

Path
  • id string required

    Account id

Query
  • filter string optional

      
        const response = await fetch('https://api.spaceinvoices.com/v1/Accounts/{id}/accessTokens', {
  method: 'GET',
  headers: {
    'Authorization': 'ACCESS_TOKEN',
    'content-type': 'application/json'
  }
});      
    

Your access token is displayed in examples.

Prerequisite: npm install node-fetch

        
          curl -X GET https://api.spaceinvoices.com/v1/Accounts/{id}/accessTokens \
  -H 'Authorization: ACCESS_TOKEN' \
  -H 'Content-Type: application/json'        
      

Your access token displayed in examples.

        
          import requests
url = 'https://api.spaceinvoices.com/v1/Accounts/{id}/accessTokens'
headers = {
  'Authorization': 'ACCESS_TOKEN',
  'content-type': 'application/json',
}
response = requests.get(url, params={}, headers=headers)        
      

Your access token displayed in examples.

Response:

    
      [
  {
    "id": "string",
    "ttl": 1209600,
    "scopes": ["string"],
    "created": "2022-04-20T10:10:30+00:00Z",
    "userId": "string"
  }
]    
  

Delete AccessToken

DELETE /v1/Accounts/:id/accessTokens/:fk

Parameters

Path
  • id string required

    Account id

  • fk string required

    Foreign key for accessTokens

      
        const response = await fetch('https://api.spaceinvoices.com/v1/Accounts/{id}/accessTokens/{fk}', {
  method: 'DELETE',
  headers: {
    'Authorization': 'ACCESS_TOKEN',
    'content-type': 'application/json'
  }
});      
    

Your access token is displayed in examples.

Prerequisite: npm install node-fetch

        
          curl -X DELETE https://api.spaceinvoices.com/v1/Accounts/{id}/accessTokens/{fk} \
  -H 'Authorization: ACCESS_TOKEN' \
  -H 'Content-Type: application/json'        
      

Your access token displayed in examples.

        
          import requests
url = 'https://api.spaceinvoices.com/v1/Accounts/{id}/accessTokens/{fk}'
headers = {
  'Authorization': 'ACCESS_TOKEN',
  'content-type': 'application/json',
}
response = requests.delete(url, params={}, headers=headers)        
      

Your access token displayed in examples.

Response:

    
      {

}