Scripts: API examples
Contract-derived requests, potential responses and API links for scripts.
Generated from the public OpenAPI. Examples illustrate the contract and are not live results. Use your assigned gateway, credentials and identifiers. The snippets do not execute automatically.
Use Node.js 22 or later. Copy the setup below into an .mjs file, set QFP_BASE_URL and QFP_ACCESS_TOKEN, then append the operation snippet you need. No repository checkout or downloaded client is required. Keep secrets in your backend and persist each write key and body before sending.
Request setup
const required = name => {
const value = process.env[name];
if (!value) throw new Error(`Set ${name} before running this example`);
return value;
};
const baseUrl = required('QFP_BASE_URL').replace(/\/$/, '');
if (!/^https:\/\//.test(baseUrl)) throw new Error('Use your assigned HTTPS gateway');
const token = required('QFP_ACCESS_TOKEN');
const segment = value => encodeURIComponent(value);
async function request(method, path, body, key) {
const headers = { Authorization: `Bearer ${token}`, 'API-Version': '1.0.0', Accept: 'application/json' };
if (key) headers['Idempotency-Key'] = key;
const multipart = body instanceof FormData;
if (body !== undefined && !multipart) headers['Content-Type'] = 'application/json';
const response = await fetch(baseUrl + path, {
method, headers, body: body === undefined ? undefined : multipart ? body : JSON.stringify(body),
signal: AbortSignal.timeout(30_000), redirect: 'error',
});
const text = await response.text();
const data = text && response.headers.get('content-type')?.includes('json') ? JSON.parse(text) : text || null;
if (!response.ok) {
const error = new Error(`HTTP ${response.status}`);
Object.assign(error, { status: response.status, data, headers: response.headers });
throw error;
}
return { status: response.status, data };
}importScript
Import a script. API Reference · Integration guide
POST /api/scripts
| Parameter | Location | Required |
|---|---|---|
API-Version | header | No |
Idempotency-Key | header | Yes |
A request body is required. The contract supplies no JSON body example here; use the linked schema. Multipart requests need FormData/file fields, not a JSON body.
const body = requestBody;
const result = await request('POST', '/api/scripts', body, required('QFP_IDEMPOTENCY_KEY'));
console.log(result.status, result.data);Replace angle-bracket placeholders before calling. Persist any idempotency key with the business instruction.
Potential responses
Documented statuses: 201, 400, 409.
For CSV/download endpoints, the response may be text rather than JSON. The request helper preserves that distinction.
getScript
Get a script. API Reference · Integration guide
GET /api/scripts/{scriptId}
| Parameter | Location | Required |
|---|---|---|
API-Version | header | No |
scriptId | path | Yes |
const body = undefined;
const result = await request('GET', '/api/scripts/' + encodeURIComponent('<scriptId>') + '', body, undefined);
console.log(result.status, result.data);Replace angle-bracket placeholders before calling. Persist any idempotency key with the business instruction.
Potential responses
Documented statuses: 200, 404.
For CSV/download endpoints, the response may be text rather than JSON. The request helper preserves that distinction.
updateScript
Update a script. API Reference · Integration guide
PATCH /api/scripts/{scriptId}
| Parameter | Location | Required |
|---|---|---|
API-Version | header | No |
scriptId | path | Yes |
Idempotency-Key | header | Yes |
A request body is required. The contract supplies no JSON body example here; use the linked schema. Multipart requests need FormData/file fields, not a JSON body.
const body = requestBody;
const result = await request('PATCH', '/api/scripts/' + encodeURIComponent('<scriptId>') + '', body, required('QFP_IDEMPOTENCY_KEY'));
console.log(result.status, result.data);Replace angle-bracket placeholders before calling. Persist any idempotency key with the business instruction.
Potential responses
Documented statuses: 200, 400, 404, 409.
Example 200 (updatedInPlace); see the reference for other outcomes.
{
"id": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
"name": "tax-optimiser",
"description": "Smart VAT tracking",
"status": "UNPUBLISHED",
"rootScriptId": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
"versionNumber": 1,
"triggerType": "BALANCE",
"scriptIds": [],
"tenantId": "d36756ac-5326-49b3-a6ed-dd3eaa3371aa",
"createdBy": "8f14e45f-ceea-467a-9a1e-1c8b4b0b5a21",
"createdAt": "2026-08-18T11:26:46.312Z",
"updatedBy": "8f14e45f-ceea-467a-9a1e-1c8b4b0b5a21",
"updatedAt": "2026-09-11T09:14:02.771Z"
}For CSV/download endpoints, the response may be text rather than JSON. The request helper preserves that distinction.
deleteScript
Delete a script. API Reference · Integration guide
DELETE /api/scripts/{scriptId}
| Parameter | Location | Required |
|---|---|---|
API-Version | header | No |
scriptId | path | Yes |
const body = undefined;
const result = await request('DELETE', '/api/scripts/' + encodeURIComponent('<scriptId>') + '', body, undefined);
console.log(result.status, result.data);Replace angle-bracket placeholders before calling. Persist any idempotency key with the business instruction.
Potential responses
Documented statuses: 204, 404, 409.
For CSV/download endpoints, the response may be text rather than JSON. The request helper preserves that distinction.
getScriptVersions
List a script's versions. API Reference · Integration guide
GET /api/scripts/{scriptId}/versions
| Parameter | Location | Required |
|---|---|---|
API-Version | header | No |
scriptId | path | Yes |
page | query | No |
size | query | No |
sort | query | No |
const body = undefined;
const result = await request('GET', '/api/scripts/' + encodeURIComponent('<scriptId>') + '/versions', body, undefined);
console.log(result.status, result.data);Replace angle-bracket placeholders before calling. Persist any idempotency key with the business instruction.
Potential responses
Documented statuses: 200, 404.
Example 200 (threeVersions); see the reference for other outcomes.
{
"content": [
{
"id": "0f3a9c62-8b1d-4e57-a2c4-9d6e5f8b7a01",
"name": "tax-optimiser_v3",
"status": "PUBLISHED",
"rootScriptId": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
"versionNumber": 3,
"previousVersionId": "b41c2f18-0d5a-4f3e-9a2b-6c7d8e9f0a1b",
"createdBy": "8f14e45f-ceea-467a-9a1e-1c8b4b0b5a21",
"createdAt": "2026-09-15T08:31:44.905Z",
"updatedBy": "8f14e45f-ceea-467a-9a1e-1c8b4b0b5a21",
"updatedAt": "2026-09-15T09:02:10.118Z"
},
{
"id": "b41c2f18-0d5a-4f3e-9a2b-6c7d8e9f0a1b",
"name": "tax-optimiser_v2",
"status": "OUTDATED",
"rootScriptId": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
"versionNumber": 2,
"previousVersionId": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
"createdBy": "8f14e45f-ceea-467a-9a1e-1c8b4b0b5a21",
"createdAt": "2026-09-11T09:14:02.771Z",
"updatedBy": "8f14e45f-ceea-467a-9a1e-1c8b4b0b5a21",
"updatedAt": "2026-09-15T08:31:44.905Z"
},
{
"id": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
"name": "tax-optimiser",
"status": "OUTDATED",
"rootScriptId": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
"versionNumber": 1,
"createdBy": "8f14e45f-ceea-467a-9a1e-1c8b4b0b5a21",
"createdAt": "2026-08-18T11:26:46.312Z",
"updatedBy": "8f14e45f-ceea-467a-9a1e-1c8b4b0b5a21",
"updatedAt": "2026-09-11T09:14:02.771Z"
}
],
"page": 0,
"size": 20,
"totalElements": 3,
"totalPages": 1
}For CSV/download endpoints, the response may be text rather than JSON. The request helper preserves that distinction.
downloadScript
Download a script's source. API Reference · Integration guide
GET /api/scripts/{scriptId}/download
| Parameter | Location | Required |
|---|---|---|
API-Version | header | No |
scriptId | path | Yes |
const body = undefined;
const result = await request('GET', '/api/scripts/' + encodeURIComponent('<scriptId>') + '/download', body, undefined);
console.log(result.status, result.data);Replace angle-bracket placeholders before calling. Persist any idempotency key with the business instruction.
Potential responses
Documented statuses: 200, 404, 409.
For CSV/download endpoints, the response may be text rather than JSON. The request helper preserves that distinction.
cloneScript
Clone a script. API Reference · Integration guide
POST /api/scripts/{scriptId}/clone
| Parameter | Location | Required |
|---|---|---|
API-Version | header | No |
scriptId | path | Yes |
Idempotency-Key | header | Yes |
const body = undefined;
const result = await request('POST', '/api/scripts/' + encodeURIComponent('<scriptId>') + '/clone', body, required('QFP_IDEMPOTENCY_KEY'));
console.log(result.status, result.data);Replace angle-bracket placeholders before calling. Persist any idempotency key with the business instruction.
Potential responses
Documented statuses: 201, 400, 404, 409.
For CSV/download endpoints, the response may be text rather than JSON. The request helper preserves that distinction.
Updated 4 days ago

