Run a plan
curl --request POST \
--url https://gateway.apiosk.com/v2/asks/{id}/run \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"max_spend": 1,
"limit": 25,
"wait_seconds": 27
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({max_spend: 1, limit: 25, wait_seconds: 27})
};
fetch('https://gateway.apiosk.com/v2/asks/{id}/run', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"status": "requires_approval",
"question": "<string>",
"plan": {
"quote_ref": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"expires_at": "2023-11-07T05:31:56Z",
"steps": [
{
"source_id": "kvk-dutch-business-register",
"operation": "company_registry.search",
"name": "<string>",
"conditional": true,
"estimated_cost": {
"amount": 0.023,
"amount_micro_usd": "23000",
"currency": "USD"
}
}
],
"estimated_total": {
"amount": 0.023,
"amount_micro_usd": "23000",
"currency": "USD"
}
},
"answer": {},
"data": {},
"results": [
{
"result_ref": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"source": {
"provider": "<string>",
"name": "<string>"
},
"data": {}
}
],
"usage": {
"sources": [
{
"source_id": "<string>",
"operation": "<string>",
"calls": 123,
"cost": {
"amount": 0.023,
"amount_micro_usd": "23000",
"currency": "USD"
}
}
],
"cost": {
"amount": 0.023,
"amount_micro_usd": "23000",
"currency": "USD"
},
"held": {
"amount": 0.023,
"amount_micro_usd": "23000",
"currency": "USD"
}
},
"balance": {
"remaining": {
"amount": 0.023,
"amount_micro_usd": "23000",
"currency": "USD"
}
},
"errors": [
{
"code": "<string>",
"message": "<string>"
}
],
"retry_after_ms": 123,
"message": "<string>",
"needs_input": [
{
"label": "<string>",
"schema": {}
}
],
"candidates": [
{}
],
"approval_required_reason": {
"code": "<string>",
"message": "<string>"
},
"metadata": {},
"continuation": {
"state": {
"schema_version": "2",
"state_ref": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"revision": 1,
"expires_at": "2023-11-07T05:31:56Z",
"focus": {
"entity_refs": [
"3c90c3cc-0d44-4b50-8888-8dd25736052a"
],
"goal_refs": [
"3c90c3cc-0d44-4b50-8888-8dd25736052a"
]
},
"state_token": "<string>"
},
"actions": [
{
"action_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"kind": "select_entity",
"label": "<string>",
"requires_authorization": false,
"input_schema": {}
}
]
}
}{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"status": "requires_approval",
"question": "<string>",
"plan": {
"quote_ref": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"expires_at": "2023-11-07T05:31:56Z",
"steps": [
{
"source_id": "kvk-dutch-business-register",
"operation": "company_registry.search",
"name": "<string>",
"conditional": true,
"estimated_cost": {
"amount": 0.023,
"amount_micro_usd": "23000",
"currency": "USD"
}
}
],
"estimated_total": {
"amount": 0.023,
"amount_micro_usd": "23000",
"currency": "USD"
}
},
"answer": {},
"data": {},
"results": [
{
"result_ref": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"source": {
"provider": "<string>",
"name": "<string>"
},
"data": {}
}
],
"usage": {
"sources": [
{
"source_id": "<string>",
"operation": "<string>",
"calls": 123,
"cost": {
"amount": 0.023,
"amount_micro_usd": "23000",
"currency": "USD"
}
}
],
"cost": {
"amount": 0.023,
"amount_micro_usd": "23000",
"currency": "USD"
},
"held": {
"amount": 0.023,
"amount_micro_usd": "23000",
"currency": "USD"
}
},
"balance": {
"remaining": {
"amount": 0.023,
"amount_micro_usd": "23000",
"currency": "USD"
}
},
"errors": [
{
"code": "<string>",
"message": "<string>"
}
],
"retry_after_ms": 123,
"message": "<string>",
"needs_input": [
{
"label": "<string>",
"schema": {}
}
],
"candidates": [
{}
],
"approval_required_reason": {
"code": "<string>",
"message": "<string>"
},
"metadata": {},
"continuation": {
"state": {
"schema_version": "2",
"state_ref": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"revision": 1,
"expires_at": "2023-11-07T05:31:56Z",
"focus": {
"entity_refs": [
"3c90c3cc-0d44-4b50-8888-8dd25736052a"
],
"goal_refs": [
"3c90c3cc-0d44-4b50-8888-8dd25736052a"
]
},
"state_token": "<string>"
},
"actions": [
{
"action_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"kind": "select_entity",
"label": "<string>",
"requires_authorization": false,
"input_schema": {}
}
]
}
}{
"error": {
"code": "invalid_source_input",
"message": "<string>",
"required_scope": "<string>",
"limit": "per_request",
"required": {
"amount": 0.023,
"amount_micro_usd": "23000",
"currency": "USD"
},
"available": {
"amount": 0.023,
"amount_micro_usd": "23000",
"currency": "USD"
},
"field": "<string>",
"missing": [
"<string>"
],
"expected": [
"<string>"
],
"operations": [
"<string>"
],
"retry_after_ms": 123
}
}{
"error": {
"code": "invalid_source_input",
"message": "<string>",
"required_scope": "<string>",
"limit": "per_request",
"required": {
"amount": 0.023,
"amount_micro_usd": "23000",
"currency": "USD"
},
"available": {
"amount": 0.023,
"amount_micro_usd": "23000",
"currency": "USD"
},
"field": "<string>",
"missing": [
"<string>"
],
"expected": [
"<string>"
],
"operations": [
"<string>"
],
"retry_after_ms": 123
}
}{
"error": {
"code": "invalid_source_input",
"message": "<string>",
"required_scope": "<string>",
"limit": "per_request",
"required": {
"amount": 0.023,
"amount_micro_usd": "23000",
"currency": "USD"
},
"available": {
"amount": 0.023,
"amount_micro_usd": "23000",
"currency": "USD"
},
"field": "<string>",
"missing": [
"<string>"
],
"expected": [
"<string>"
],
"operations": [
"<string>"
],
"retry_after_ms": 123
}
}{
"error": {
"code": "invalid_source_input",
"message": "<string>",
"required_scope": "<string>",
"limit": "per_request",
"required": {
"amount": 0.023,
"amount_micro_usd": "23000",
"currency": "USD"
},
"available": {
"amount": 0.023,
"amount_micro_usd": "23000",
"currency": "USD"
},
"field": "<string>",
"missing": [
"<string>"
],
"expected": [
"<string>"
],
"operations": [
"<string>"
],
"retry_after_ms": 123
}
}{
"error": {
"code": "invalid_source_input",
"message": "<string>",
"required_scope": "<string>",
"limit": "per_request",
"required": {
"amount": 0.023,
"amount_micro_usd": "23000",
"currency": "USD"
},
"available": {
"amount": 0.023,
"amount_micro_usd": "23000",
"currency": "USD"
},
"field": "<string>",
"missing": [
"<string>"
],
"expected": [
"<string>"
],
"operations": [
"<string>"
],
"retry_after_ms": 123
}
}{
"error": {
"code": "invalid_source_input",
"message": "<string>",
"required_scope": "<string>",
"limit": "per_request",
"required": {
"amount": 0.023,
"amount_micro_usd": "23000",
"currency": "USD"
},
"available": {
"amount": 0.023,
"amount_micro_usd": "23000",
"currency": "USD"
},
"field": "<string>",
"missing": [
"<string>"
],
"expected": [
"<string>"
],
"operations": [
"<string>"
],
"retry_after_ms": 123
}
}{
"error": {
"code": "invalid_source_input",
"message": "<string>",
"required_scope": "<string>",
"limit": "per_request",
"required": {
"amount": 0.023,
"amount_micro_usd": "23000",
"currency": "USD"
},
"available": {
"amount": 0.023,
"amount_micro_usd": "23000",
"currency": "USD"
},
"field": "<string>",
"missing": [
"<string>"
],
"expected": [
"<string>"
],
"operations": [
"<string>"
],
"retry_after_ms": 123
}
}{
"error": {
"code": "invalid_source_input",
"message": "<string>",
"required_scope": "<string>",
"limit": "per_request",
"required": {
"amount": 0.023,
"amount_micro_usd": "23000",
"currency": "USD"
},
"available": {
"amount": 0.023,
"amount_micro_usd": "23000",
"currency": "USD"
},
"field": "<string>",
"missing": [
"<string>"
],
"expected": [
"<string>"
],
"operations": [
"<string>"
],
"retry_after_ms": 123
}
}{
"error": {
"code": "invalid_source_input",
"message": "<string>",
"required_scope": "<string>",
"limit": "per_request",
"required": {
"amount": 0.023,
"amount_micro_usd": "23000",
"currency": "USD"
},
"available": {
"amount": 0.023,
"amount_micro_usd": "23000",
"currency": "USD"
},
"field": "<string>",
"missing": [
"<string>"
],
"expected": [
"<string>"
],
"operations": [
"<string>"
],
"retry_after_ms": 123
}
}{
"error": {
"code": "invalid_source_input",
"message": "<string>",
"required_scope": "<string>",
"limit": "per_request",
"required": {
"amount": 0.023,
"amount_micro_usd": "23000",
"currency": "USD"
},
"available": {
"amount": 0.023,
"amount_micro_usd": "23000",
"currency": "USD"
},
"field": "<string>",
"missing": [
"<string>"
],
"expected": [
"<string>"
],
"operations": [
"<string>"
],
"retry_after_ms": 123
}
}API Reference
Run a plan
Approve the plan against this key’s limits and run it. Running twice is the same run. Requires ask:execute.
POST
/
v2
/
asks
/
{id}
/
run
Run a plan
curl --request POST \
--url https://gateway.apiosk.com/v2/asks/{id}/run \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"max_spend": 1,
"limit": 25,
"wait_seconds": 27
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({max_spend: 1, limit: 25, wait_seconds: 27})
};
fetch('https://gateway.apiosk.com/v2/asks/{id}/run', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"status": "requires_approval",
"question": "<string>",
"plan": {
"quote_ref": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"expires_at": "2023-11-07T05:31:56Z",
"steps": [
{
"source_id": "kvk-dutch-business-register",
"operation": "company_registry.search",
"name": "<string>",
"conditional": true,
"estimated_cost": {
"amount": 0.023,
"amount_micro_usd": "23000",
"currency": "USD"
}
}
],
"estimated_total": {
"amount": 0.023,
"amount_micro_usd": "23000",
"currency": "USD"
}
},
"answer": {},
"data": {},
"results": [
{
"result_ref": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"source": {
"provider": "<string>",
"name": "<string>"
},
"data": {}
}
],
"usage": {
"sources": [
{
"source_id": "<string>",
"operation": "<string>",
"calls": 123,
"cost": {
"amount": 0.023,
"amount_micro_usd": "23000",
"currency": "USD"
}
}
],
"cost": {
"amount": 0.023,
"amount_micro_usd": "23000",
"currency": "USD"
},
"held": {
"amount": 0.023,
"amount_micro_usd": "23000",
"currency": "USD"
}
},
"balance": {
"remaining": {
"amount": 0.023,
"amount_micro_usd": "23000",
"currency": "USD"
}
},
"errors": [
{
"code": "<string>",
"message": "<string>"
}
],
"retry_after_ms": 123,
"message": "<string>",
"needs_input": [
{
"label": "<string>",
"schema": {}
}
],
"candidates": [
{}
],
"approval_required_reason": {
"code": "<string>",
"message": "<string>"
},
"metadata": {},
"continuation": {
"state": {
"schema_version": "2",
"state_ref": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"revision": 1,
"expires_at": "2023-11-07T05:31:56Z",
"focus": {
"entity_refs": [
"3c90c3cc-0d44-4b50-8888-8dd25736052a"
],
"goal_refs": [
"3c90c3cc-0d44-4b50-8888-8dd25736052a"
]
},
"state_token": "<string>"
},
"actions": [
{
"action_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"kind": "select_entity",
"label": "<string>",
"requires_authorization": false,
"input_schema": {}
}
]
}
}{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"status": "requires_approval",
"question": "<string>",
"plan": {
"quote_ref": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"expires_at": "2023-11-07T05:31:56Z",
"steps": [
{
"source_id": "kvk-dutch-business-register",
"operation": "company_registry.search",
"name": "<string>",
"conditional": true,
"estimated_cost": {
"amount": 0.023,
"amount_micro_usd": "23000",
"currency": "USD"
}
}
],
"estimated_total": {
"amount": 0.023,
"amount_micro_usd": "23000",
"currency": "USD"
}
},
"answer": {},
"data": {},
"results": [
{
"result_ref": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"source": {
"provider": "<string>",
"name": "<string>"
},
"data": {}
}
],
"usage": {
"sources": [
{
"source_id": "<string>",
"operation": "<string>",
"calls": 123,
"cost": {
"amount": 0.023,
"amount_micro_usd": "23000",
"currency": "USD"
}
}
],
"cost": {
"amount": 0.023,
"amount_micro_usd": "23000",
"currency": "USD"
},
"held": {
"amount": 0.023,
"amount_micro_usd": "23000",
"currency": "USD"
}
},
"balance": {
"remaining": {
"amount": 0.023,
"amount_micro_usd": "23000",
"currency": "USD"
}
},
"errors": [
{
"code": "<string>",
"message": "<string>"
}
],
"retry_after_ms": 123,
"message": "<string>",
"needs_input": [
{
"label": "<string>",
"schema": {}
}
],
"candidates": [
{}
],
"approval_required_reason": {
"code": "<string>",
"message": "<string>"
},
"metadata": {},
"continuation": {
"state": {
"schema_version": "2",
"state_ref": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"revision": 1,
"expires_at": "2023-11-07T05:31:56Z",
"focus": {
"entity_refs": [
"3c90c3cc-0d44-4b50-8888-8dd25736052a"
],
"goal_refs": [
"3c90c3cc-0d44-4b50-8888-8dd25736052a"
]
},
"state_token": "<string>"
},
"actions": [
{
"action_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"kind": "select_entity",
"label": "<string>",
"requires_authorization": false,
"input_schema": {}
}
]
}
}{
"error": {
"code": "invalid_source_input",
"message": "<string>",
"required_scope": "<string>",
"limit": "per_request",
"required": {
"amount": 0.023,
"amount_micro_usd": "23000",
"currency": "USD"
},
"available": {
"amount": 0.023,
"amount_micro_usd": "23000",
"currency": "USD"
},
"field": "<string>",
"missing": [
"<string>"
],
"expected": [
"<string>"
],
"operations": [
"<string>"
],
"retry_after_ms": 123
}
}{
"error": {
"code": "invalid_source_input",
"message": "<string>",
"required_scope": "<string>",
"limit": "per_request",
"required": {
"amount": 0.023,
"amount_micro_usd": "23000",
"currency": "USD"
},
"available": {
"amount": 0.023,
"amount_micro_usd": "23000",
"currency": "USD"
},
"field": "<string>",
"missing": [
"<string>"
],
"expected": [
"<string>"
],
"operations": [
"<string>"
],
"retry_after_ms": 123
}
}{
"error": {
"code": "invalid_source_input",
"message": "<string>",
"required_scope": "<string>",
"limit": "per_request",
"required": {
"amount": 0.023,
"amount_micro_usd": "23000",
"currency": "USD"
},
"available": {
"amount": 0.023,
"amount_micro_usd": "23000",
"currency": "USD"
},
"field": "<string>",
"missing": [
"<string>"
],
"expected": [
"<string>"
],
"operations": [
"<string>"
],
"retry_after_ms": 123
}
}{
"error": {
"code": "invalid_source_input",
"message": "<string>",
"required_scope": "<string>",
"limit": "per_request",
"required": {
"amount": 0.023,
"amount_micro_usd": "23000",
"currency": "USD"
},
"available": {
"amount": 0.023,
"amount_micro_usd": "23000",
"currency": "USD"
},
"field": "<string>",
"missing": [
"<string>"
],
"expected": [
"<string>"
],
"operations": [
"<string>"
],
"retry_after_ms": 123
}
}{
"error": {
"code": "invalid_source_input",
"message": "<string>",
"required_scope": "<string>",
"limit": "per_request",
"required": {
"amount": 0.023,
"amount_micro_usd": "23000",
"currency": "USD"
},
"available": {
"amount": 0.023,
"amount_micro_usd": "23000",
"currency": "USD"
},
"field": "<string>",
"missing": [
"<string>"
],
"expected": [
"<string>"
],
"operations": [
"<string>"
],
"retry_after_ms": 123
}
}{
"error": {
"code": "invalid_source_input",
"message": "<string>",
"required_scope": "<string>",
"limit": "per_request",
"required": {
"amount": 0.023,
"amount_micro_usd": "23000",
"currency": "USD"
},
"available": {
"amount": 0.023,
"amount_micro_usd": "23000",
"currency": "USD"
},
"field": "<string>",
"missing": [
"<string>"
],
"expected": [
"<string>"
],
"operations": [
"<string>"
],
"retry_after_ms": 123
}
}{
"error": {
"code": "invalid_source_input",
"message": "<string>",
"required_scope": "<string>",
"limit": "per_request",
"required": {
"amount": 0.023,
"amount_micro_usd": "23000",
"currency": "USD"
},
"available": {
"amount": 0.023,
"amount_micro_usd": "23000",
"currency": "USD"
},
"field": "<string>",
"missing": [
"<string>"
],
"expected": [
"<string>"
],
"operations": [
"<string>"
],
"retry_after_ms": 123
}
}{
"error": {
"code": "invalid_source_input",
"message": "<string>",
"required_scope": "<string>",
"limit": "per_request",
"required": {
"amount": 0.023,
"amount_micro_usd": "23000",
"currency": "USD"
},
"available": {
"amount": 0.023,
"amount_micro_usd": "23000",
"currency": "USD"
},
"field": "<string>",
"missing": [
"<string>"
],
"expected": [
"<string>"
],
"operations": [
"<string>"
],
"retry_after_ms": 123
}
}{
"error": {
"code": "invalid_source_input",
"message": "<string>",
"required_scope": "<string>",
"limit": "per_request",
"required": {
"amount": 0.023,
"amount_micro_usd": "23000",
"currency": "USD"
},
"available": {
"amount": 0.023,
"amount_micro_usd": "23000",
"currency": "USD"
},
"field": "<string>",
"missing": [
"<string>"
],
"expected": [
"<string>"
],
"operations": [
"<string>"
],
"retry_after_ms": 123
}
}{
"error": {
"code": "invalid_source_input",
"message": "<string>",
"required_scope": "<string>",
"limit": "per_request",
"required": {
"amount": 0.023,
"amount_micro_usd": "23000",
"currency": "USD"
},
"available": {
"amount": 0.023,
"amount_micro_usd": "23000",
"currency": "USD"
},
"field": "<string>",
"missing": [
"<string>"
],
"expected": [
"<string>"
],
"operations": [
"<string>"
],
"retry_after_ms": 123
}
}Authorizations
An organisation API key: Authorization: Bearer apk_org_live_…
Path Parameters
Body
application/json
Response
Success
Available options:
requires_approval, running, completed, partial, needs_input, needs_selection, unsupported, cancelled, failed Show child attributes
Show child attributes
Apiosk's reading of the results, with evidence pointers. Null for a direct call.
The source document, when the run produced exactly one.
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Natural-language clarification for needs_input.
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Attribution for a single result, when present.
Show child attributes
Show child attributes

