Developers: integrate with Metrak
Connect Metrak to your ERP, accounting or BI tools: read and update records through the API, import and export in bulk, and get webhooks when things change.
Getting started
Integrations is a paid add-on. An Admin turns it on in Add-ons, then switches integrations on in Settings → Integrations. Metrak then creates an integration account that every API request acts as. It never signs in and does not take a team seat.
- Create an access token: give it a name, choose what it can read and change, and optionally limit it to some projects.
- Copy the token straight away. It is shown once; if you lose it, revoke it and create a new one.
- The API address is https://metrak.ai/api
Authentication and errors
Send the token in the Authorization header of every request.
curl https://metrak.ai/api/supplier \ -H "Authorization: Bearer mtk_your_token"
- 401: the token is wrong, expired or revoked, or integrations are switched off.
- 403: the token or the Integration account role does not allow this module or action, the record is outside the token’s projects, or the endpoint is not open to tokens.
- 429: more than 120 requests a minute with this token. Wait the number of seconds in Retry-After.
- Error bodies are JSON with a message and, where useful, a code.
What a token can do
Two limits apply and both must allow an action: the Integration account role (Settings → Roles, which an Admin can change) and the token’s own module and action choices. A token limited to projects only sees and writes records of those projects.
Tokens can use the record endpoints of every module, and import and export. Sign-in, team, roles, settings, billing, AI and the integrations settings are never open to tokens.
Reading and writing records
Every module has the same endpoints. The module name is the one in the URL: for example supplier, task, project, invoice, purchaserequest or dailyprogressreport. The webhook form in Settings → Integrations lists them all.
GET https://metrak.ai/api/{module} list
GET https://metrak.ai/api/{module}/{id} one record
POST https://metrak.ai/api/{module} create
PUT https://metrak.ai/api/{module}/{id} replace (send every field)
DELETE https://metrak.ai/api/{module}/{id} delete
GET https://metrak.ai/api/{module}/{id}/revisions change history- PUT replaces the whole record, so send every field. To change only a few fields, use import in update mode: fields you leave out keep their values.
- Every create and change goes through the same checks as the app: permissions, plan limits, project access, numbering and approval rules.
Exporting and syncing
GET /api/{module}/data/export returns records oldest change first, a page at a time. Keep the last nextCursor: next time, send it as after and you get exactly what changed since.
curl "https://metrak.ai/api/supplier/data/export?pageSize=500&after=638650000000000000_6ad8db7e..." \ -H "Authorization: Bearer mtk_your_token"
- pageSize: 1 to 500 (default 100).
- after: the cursor from the previous page or the previous sync.
- updatedSince: only records changed after this date and time (ISO 8601).
- projectId: only records of one project.
- includeDeleted=true: deleted records come back as { "id", "deleted": true } so your copy can remove them.
- format=csv: the same page as a CSV file (the next cursor is in the X-Next-Cursor header).
{
"module": "supplier",
"items": [
{
"id": "6ad8db7eb432d85577311a2b",
"externalId": "ERP-1042",
"createdAt": "2026-10-21T15:34:22Z",
"updatedAt": "2026-10-21T15:40:10Z",
"deleted": false,
"data": { "id": "6ad8db7eb432d85577311a2b", "name": "Amman Steel", "phone": "0790000000", "city": "Amman" }
}
],
"hasMore": true,
"nextCursor": "638650000000000000_6ad8db7eb432d85577311a2b"
}Importing
POST /api/{module}/data/import creates or updates up to 1,000 records in one request and reports the outcome of each row. Rows are matched by Metrak id or by externalId, your own system’s id, which is stored on the record and is unique per module.
curl -X POST https://metrak.ai/api/supplier/data/import \
-H "Authorization: Bearer mtk_your_token" \
-H "Content-Type: application/json" \
-d '{
"mode": "upsert",
"dryRun": false,
"rows": [
{ "externalId": "ERP-1042", "data": { "name": "Amman Steel", "phone": "0790000000" } },
{ "externalId": "ERP-1043", "data": { "name": "Zarqa Cement" } }
]
}'- mode: create (new records only), update (existing only) or upsert (either, the default).
- dryRun: true checks every row and saves nothing.
- rows: each with id or externalId, and data holding the module’s fields. On update, fields you leave out keep their values.
- csv: instead of rows, send CSV text with a header row. Empty cells are ignored; columns that are not fields of the module are listed in ignoredColumns.
- Each row reports created, updated, skipped or error, with a code: invalid_data, forbidden, not_found, external_id_taken or plan_limit.
{
"module": "supplier", "mode": "upsert", "dryRun": false,
"total": 2, "created": 1, "updated": 1, "skipped": 0, "failed": 0,
"ignoredColumns": [],
"rows": [
{ "index": 0, "status": "updated", "id": "6ad8db7eb432d85577311a2b", "externalId": "ERP-1042" },
{ "index": 1, "status": "created", "id": "6ad8db80b432d85577311a6c", "externalId": "ERP-1043" }
]
}Webhooks
Add a webhook in Settings → Integrations → Webhooks: an HTTPS address and the events to send. Events are module.action, where the action is created, updated, deleted, approved or rejected: for example supplier.created or purchaserequest.approved. Use module.* for every action of a module, or * for everything. A webhook can be limited to some projects.
POST https://your-system.example.com/metrak-webhook
Content-Type: application/json
X-Metrak-Event: purchaserequest.approved
X-Metrak-Event-Id: 6ad8de2ebd2cb4c33c674188
X-Metrak-Delivery: 6ad8de2ebd2cb4c33c674189
X-Metrak-Timestamp: 1792597550
X-Metrak-Signature: t=1792597550,v1=5f2c...e81a
{
"id": "6ad8de2ebd2cb4c33c674188",
"event": "purchaserequest.approved",
"occurredAt": "2026-10-21T15:45:50Z",
"companyId": "6ad8de0cff081c50c4d22680",
"module": "purchaserequest",
"action": "approved",
"recordId": "6ad8de2dbd2cb4c33c674180",
"externalId": "ERP-PR-77",
"projectId": "6ad8de0dff081c50c4d226a1",
"status": "Approved",
"actorId": "6b38fc4c-b575-4afd-b9f7-781f06286762",
"url": "/api/purchaserequest/6ad8de2dbd2cb4c33c674180"
}- Events carry ids, not the record’s fields: fetch the record from url with your token, so you only ever see what the token may see.
- Answer with a 2xx status within 10 seconds, then do the work.
- Failed deliveries are tried again after 1 minute, 5 minutes, 30 minutes, 2 hours and 12 hours. After 10 deliveries in a row fail, the webhook is switched off and Admins get an email.
- The same event can arrive more than once: use its id to ignore repeats.
- Send test and the delivery log in Settings help you check your endpoint; Redeliver sends an event again.
Verifying webhook signatures
Every request carries X-Metrak-Signature: t={timestamp},v1={signature}. The signature is the HMAC-SHA256, in hex, of "{timestamp}.{raw body}" with the webhook’s signing secret (whsec_…). Check it before trusting the event, and reject requests whose timestamp is more than 5 minutes old. New secret in Settings issues a new one; the old one stops at once.
// Node.js (Express): verify before trusting the event.
import crypto from 'node:crypto'
app.post('/metrak-webhook', express.raw({ type: 'application/json' }), (req, res) => {
const header = req.get('X-Metrak-Signature') ?? '' // "t=...,v1=..."
const parts = Object.fromEntries(header.split(',').map((p) => p.split('=')))
const body = req.body.toString('utf8') // the raw body, unchanged
const expected = crypto.createHmac('sha256', process.env.METRAK_WEBHOOK_SECRET)
.update(`${parts.t}.${body}`).digest('hex')
const fresh = Math.abs(Date.now() / 1000 - Number(parts.t)) < 300
const valid = fresh && parts.v1?.length === expected.length &&
crypto.timingSafeEqual(Buffer.from(parts.v1), Buffer.from(expected))
if (!valid) return res.status(400).end()
res.status(200).end() // answer fast...
handle(JSON.parse(body)) // ...then do the work
})Connecting your ERP (Business Central, Sage X3, SAP, CMiC)
With the ERP connectors add-on, Metrak keeps your ERP in step without writing code. An Admin connects Microsoft Dynamics 365 Business Central or Sage X3 (GraphQL API or SOAP web services) in Settings → Integrations → Connected systems.
Records go to the ERP as they are saved: suppliers, clients, projects, purchase invoices once received, expenses and payments as journal lines, sales invoices and certified valuations. Linked records go first: an invoice brings its supplier and project. Invoices arrive as drafts, and posting stays in the ERP. Payment status and supplier changes come back to Metrak.
- Field mapping: each flow starts from a ready mapping. Change any field, combine fields with templates, set fixed values, translate codes with value tables (tax, payment types, currencies, accounts) and preview what would be sent before switching on.
- Map with AI: paste one record from the ERP (or its API documentation) as JSON and the AI proposes the mapping, showing what is new or changed and what Metrak would send. Use it, edit it, or discard it; nothing is saved until you press Save. Uses 1 AI credit.
- First sync: suppliers already in the ERP are matched by tax number or name and listed for review. Link, create or ignore each one; nothing is created until you apply.
- Sync log: every record sent or received, with the ERP's own message when it refuses one. Outages are retried automatically; Send again resends a record once it is fixed.
- Business Central: register an app in Microsoft Entra, give it API.ReadWrite.All and add it in Business Central (Microsoft Entra applications). In the connection, set the G/L accounts for invoice lines and the general journal.
- SAP S/4HANA: a communication user with the Business Partner, Enterprise Project, Supplier Invoice and Journal Entry arrangements. Suppliers and clients become business partners, purchase invoices supplier invoices, and expenses, payments, sales invoices and valuations balanced journal entries. CMiC: a CMiC user on its REST API; vendors, jobs, AP invoices, AR bills and journals, with fields read from the API itself.
- Sage X3: the GraphQL API signs in as a connected application; SOAP uses a web service pool with a user and password. Code lists differ between sites, so value tables are typed in, and object names can be changed under Advanced.
- Connections act as the integration account, and only an Admin can manage them. Secrets are stored encrypted and never shown again.
- More connections, set up in the app without code, each its own add-on: equipment telematics (any maker with the ISO 15143-3 / AEMP 2.0 feed, or Tenna) for machine hours, fuel, position and faults; Primavera P6 (XER, P6 XML or P6 EPPM) for the programme and progress; BIM models (IFC from Revit or Tekla, Autodesk Platform Services, Trimble Connect) for quantities into the BOQ. The user guide explains each one.
Accounting systems and any other system
Connected systems also cover QuickBooks Online, Xero, Zoho Books and Odoo, and a one-time import from Procore. For any other system with a REST API (JSON or XML), pick Custom system (REST / XML): the connection is described by its endpoints and fields, so no code is needed on either side.
Set up with AI drafts the whole connection for you: describe what should sync, paste sample records (JSON or XML) or attach the system’s API documents (OpenAPI, WSDL, PDF, Word, images or text; up to 3 files of 10 MB). The draft shows the system, its address and sign-in, the endpoints, fields and mappings, and the checks to make before switching on. Nothing is saved until you apply it.
- AI never fills passwords, keys or secrets: enter them in the Connection tab after applying, then Save and test.
- Change with AI updates an existing connection - a new flow, other fields or a different endpoint - and shows the changes for review first.
- Prefer to write it yourself? Edit as JSON shows the full definition; Use this JSON applies your version.
- Each draft uses 1 AI credit, refunded if the AI fails.