Discovery API
Signature Tokens
Signature Token object
Properties | |
token |
string |
name |
string |
creator_id |
integer |
organization_id |
integer |
access_key |
string |
access_secret |
string |
created_at |
datetime |
expires_at |
datetime |
updated_at |
datetime |
authentication_for |
string |
authorization_type |
string |
{
"token": "5b89bf4b0a49",
"name": "batch-api-token-1",
"creator_id": 3,
"organization_id": 4,
"access_key": "8b6fdc0a36bf340604a3cedc",
"access_secret": "829146cb6c752f51bbbb8c85",
"created_at": "2020-07-02T21:01:17.181Z",
"updated_at": "2020-07-02T21:01:17.181Z",
"expires_at": "2020-10-02T21:00:00.000Z",
"authentication_for": "batch-api",
"authorization_type": "read-only"
}
Create a Signature Token
To return a valid signature token (to then be used for batch API requests) send a POST request.
signature_token
should be a top level key in the raw data sent.
name
is required to be a string between 4-64 characters longexpires_at
must be in ISO8601 (YYYY-MM-DDTHH:mmZ) formatauth_scope
must be a JSON object.authentication_for
andauthorization_type
are the only valid keys.batch-api
is the only valid value forauthentication_for
.read-only
is the only valid value forauthorization_type
.
Example POST body:
"signature_token": {
"name": "token-name-here",
"expires_at": "2024-10-02T21:00:00+0000",
"auth_scope": { "authentication_for" : "batch-api",
"authorization_type": "read-only" }
}
URL Params | ||
workspace required |
string |
Workspace username
|
Responses | |
200 |
SignatureToken response |
401 |
Unauthorized |
404 |
Workspace not found |
POST
/batch/{workspace}
curl --location --request POST 'https://app.mode.com/batch/{workspace}/signature_tokens' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--user 'your-api-key':'your-api-secret' \
--data-raw '{
"signature_token": {
"name": "batch-api-token",
"expires_at": "2024-10-02T21:00:00+0000",
"auth_scope": { "authentication_for" : "batch-api", "authorization_type": "read-only" }
}
}';
require 'http'
username = 'your_api_key'
password = 'your_api_secret'
headers = {
content_type: 'application/json',
accept: 'application/json'
}
form_data = {
"signature_token": {
"name": "batch-api-token",
"expires_at": "2024-10-02T21:00:00+0000",
"auth_scope": {
"authentication_for": "batch-api",
"authorization_type": "read-only"
}
}
}
response = HTTP.basic_auth(user: username, pass: password)
.headers(headers)
.post('https://app.mode.com/batch/{workspace}/signature_tokens', json: form_data)
puts response
import requests
from requests.auth import HTTPBasicAuth
from base64 import b64encode
host = 'https://app.mode.com'
username = 'xxxx'
password = 'xxxxx'
ws = 'xxx' # Note: workspace_name value should be all lowercase
username_pw = '{}:{}'.format(username, password).encode('utf-8')
basic_auth_creds = b64encode(username_pw)
form_data = {
"signature_token": {
"name": "batch_api_name",
"expires_at": "2024-10-02T21:00:00+0000",
"auth_scope": {
"authentication_for": "batch-api",
"authorization_type": "read-only"
}
}
}
discovery_url = '{}/batch/{}/signature_tokens'.format(host, ws)
HEADERS = {
'Authorization': 'Basic {}'.format(basic_auth_creds),
'Accept': 'application/json',
'Content-Type': 'application/json'
}
response = requests.post(discovery_url, headers=HEADERS, json=form_data, auth=(username, password))
result = response.json()
print(result)
var request = new XMLHttpRequest();
var basic_auth = 'Basic ' + btoa('your-api-key:your-api-secret');
var form_data = {
"signature_token": {
"name": "batch-api-token",
"expires_at": "2024-10-02T21:00:00+0000",
"auth_scope": {
"authentication_for": "batch-api",
"authorization_type": "read-only"
}
}
};
request.open('POST', 'https://app.mode.com/batch/{workspace}/signature_tokens');
request.withCredentials = true;
request.setRequestHeader('Authorization', basic_auth);
request.setRequestHeader('Content-Type', 'application/json');
request.setRequestHeader('Accept', 'application/json');
request.onreadystatechange = function () {
if (this.readyState === 4) {
console.log('Status:', this.status);
console.log('Headers:', this.getAllResponseHeaders());
console.log('Body:', this.responseText);
}
};
request.send(JSON.stringify(form_data));
Delete a Signature Token
URL Params | ||
workspace required |
string |
Workspace username
|
signature_token required |
string | Signature Token token |
Responses | |
200 |
SignatureToken response |
401 |
Unauthorized |
404 |
SignatureToken not found |
DELETE
/batch/{workspace}
curl --location --request DELETE 'https://goat.farm:3000/batch/{workspace}/signature_tokens/{signature_token}' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--user 'your-api-key':'your-api-secret' \
require 'http'
username = 'your_api_key'
password = 'your_api_secret'
headers = {
content_type: 'application/json',
accept: 'application/json'
}
response = HTTP.basic_auth(user: username, pass: password)
.headers(headers)
.delete('https://app.mode.com/batch/{workspace}/signature_tokens/{signature_token}')
puts response
from urllib2 import Request, urlopen
from base64 import b64encode
username = 'your-api-key'
password = 'your-api-secret'
basic_auth_creds = b64encode('%s:%s' % (username, password))
request = Request('https://app.mode.com/batch/{workspace}/signature_tokens/{signature_token}')
request.add_header("Authorization", "Basic %s" % basic_auth_creds)
request.add_header("Accept", "application/json")
request.add_header("Content-Type", "application/json")
request.get_method = lambda: 'DELETE'
response = urlopen(request)
response_body = response.read()
print(response_body)
var request = new XMLHttpRequest();
var basic_auth = 'Basic ' + btoa('your-api-key:your-api-secret');
request.open('DELETE', 'https://app.mode.com/batch/{workspace}/signature_tokens/{signature_token}');
request.withCredentials = true;
request.setRequestHeader('Authorization', basic_auth);
request.setRequestHeader('Content-Type', 'application/json');
request.setRequestHeader('Accept', 'application/json');
request.onreadystatechange = function () {
if (this.readyState === 4) {
console.log('Status:', this.status);
console.log('Headers:', this.getAllResponseHeaders());
console.log('Body:', this.responseText);
}
};
request.send();