Admin Subscriber

Only an admin subscriber can create tokens, tables, retrieve table informations and change table schema.

Creating a token

request

[POST] https://{{subdomain}}.syncode.cloud/create_token

fielddescriptionrequirednotes
subscribersubsriber type of entitytrue
subscriber_idunique id of the entitytrue
writearray of tables grantedfalseif not specified all tables are granted
readarray of tables grantedfalseif not specified all tables are granted
filterslist of subscribers or subscibers_id to grant accessfalseif none specified no restrictions made, if both specified only ids are considered

Example

The token created is for a machine subscriber with machine0 id. It can access with RW permissions the table demo_table and can see only the data inserted by himself!

let token = `<provided token>`
let organization = 'demo'
let Authorization = `Bearer ${token}`
let body = {
subscriber: 'machine',
id: 'machine0',
read : ['demo_table'],
write: ['demo_table'],
filters: {
ids: ['machine0']
}
}
fetch(`https://${organization}.syncode.cloud/create_token`, {
method: 'POST',
headers: {
Authorization
},
body
})

Creating a table

request

[POST] https://{{subdomain}}.syncode.cloud/create_table

fielddescriptionrequirednotes
namethe table nametrue

Example

Let's create the demo_table!

let token = `<provided token>`
let organization = 'demo'
let Authorization = `Bearer ${token}`
let body = {
name: 'demo_table',
}
fetch(`https://${organization}.syncode.cloud/create_table`, {
method: 'POST',
headers: {
Authorization
},
body
})

Altering a table

We want to store the state of the machine, the temperature and a message.

request

[POST] https://{{subdomain}}.syncode.cloud/alter_table

fielddescriptionrequirednotes
destinationthe table nametrue
datakey-value object: column-typetruetypes: [ 'Boolean', 'text', 'timestamp', 'float', 'double', 'int' ]

Example

let token = `<provided token>`
let organization = 'demo'
let Authorization = `Bearer ${token}`
let body = {
destination: 'demo_table',
data: {
start: 'Boolean',
temperature: 'float',
message: 'text'
}
}
fetch(`https://${organization}.syncode.cloud/alter_table`, {
method: 'POST',
headers: {
Authorization
},
body
})