Approve or deny
const url = 'http://127.0.0.1:7700/api/approvals/t3k9x2a1b2.budget.example.spend%3A9f2c41d07a6be315';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"approved":true,"by":"portal"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url http://127.0.0.1:7700/api/approvals/t3k9x2a1b2.budget.example.spend%3A9f2c41d07a6be315 \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "approved": true, "by": "portal" }'Answers one approval. The first answer wins: an approval that is already answered is returned
unchanged. approved must be true to approve; any other value denies.
From a paired device, the log records the device’s name as who answered, whatever by says. by
is used only when the box’s own screen answers. Percent-encode an id that holds spaces, such as
one made from Droid’s own question.
An Apple Watch token may approve only up to Settings watchLimitCents, never on a Business box,
never a Shopper purchase, and only with auth: wrist. Otherwise the answer is 403 with
needs: iphone and the request keeps waiting. A Watch may always deny. On a GurtOS Business box
only a person answers, never their own request, only what the policy sends to them and only within
their limit. A refusal is 403 with the reason, and the request keeps waiting.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”The approval id. <task id>.budget.<action> is the box’s own spend question, <task id>.task.<key> a question the task asked, <task id>.tool.<call>.ask.<hash> a question a tool asked.
Example
t3k9x2a1b2.budget.example.spend:9f2c41d07a6be315Request Bodyrequired
Section titled “Request Bodyrequired”object
true approves. Anything else denies.
Who answered, for the log, when the box’s own screen answers. Default api. Ignored from a paired device.
How a native app says it checked that it was you. The log keeps it as reported, never as proof.
Example
{ "approved": true, "by": "portal"}Responses
Section titled “Responses”The approval after the answer, or as it was if someone answered first.
object
<task id>.budget.<action> for the box’s own spend question, <task id>.task.<key> for a question the task asked, <task id>.tool.<call>.ask.<hash> for one a tool asked, <task id>.shadow.<action> for a Business shadow request. The same key asked twice is the same approval. A task can only name keys under task., so it cannot pre-answer the box’s own questions.
The question shown to people.
The spending being asked about
Who gets paid
What the spend or action is for.
Who answered: a paired device’s name, what the box’s own screen sent (such as box screen), jira:<name>, asi1, undo, or task ended. On Business, the person’s name.
Business: the id of the person who answered.
Business: the phone or screen the answer came from. A native app’s auth is kept here as reported.
Business: the id of the person who asked for the task. They may not answer it.
Business: where the policy sent a request, and why.
object
The policy line that matched, such as Over $10,000 goes to the Controller.
Who it goes to as the policy says it: the Controller, IT, any approver.
The amount the rules and limits were checked against
The people who could approve it when it was asked.
object
One sentence for people.
Business shadow mode: the seat this is a suggestion from.
Example
{ "state": "pending"}No approval with this id.
object
What went wrong
Example
{ "error": "no approval t3k9x2a1b2.task.deploy"}An outside request with no device token, or with one that is unknown or revoked.
object
What went wrong
Example
{ "error": "pair this phone with this computer first"}A Watch token over its limit, a Business refusal, or an app’s window answering another app’s request. The Watch and window refusals carry needs.
object
Where it may be answered instead: iphone, or shell (GurtOS itself, not an app window).
With needs: shell, the task whose request it is.
Example
{ "error": "Approve this on your iPhone: the Watch approves up to $25.00.", "needs": "iphone"}