PARSER GUIDES
Custom Code Export
Integrations
Run JavaScript after document processing to send data through one or more API calls
Custom Code Export runs your JavaScript after PARSER processes a document. Use it when you need to look up records, create missing records, send line items, or call several APIs in one export.
Add the export
1. Open a parser and go to Settings -> Integrations.
2. Find Custom Code Export under Direct exports and click Add.
3. Expand the new integration under Added integrations.
Each parser can have one Custom Code Export. The code can call several services or perform several steps.
Add a secret
Use secrets for API keys, access tokens, and other private values.
1. Open the Secrets tab.
2. Enter an uppercase name such as HUBSPOT_API_KEY.
3. Enter the secret value and click Add secret.
The value is hidden after you save it. You can replace or delete it, but you cannot view it again. Use it in code as secrets.HUBSPOT_API_KEY.
Anyone who can manage parser integrations can use these secrets through code. Give this permission only to trusted team members.
Write the code
Open the Code tab. Your code can use:
datafor extracted fields and tablesdocumentfor the document ID, name, URL, parser ID, and workflow run IDsecretsfor values saved in the Secrets tabaxiosfor HTTP requestsconsole.log()for execution logs
The code supports asynchronous requests, functions, loops, conditions, and normal error handling. It runs for up to 30 seconds.
Generate code with AI
Click Ask AI to Write Code in the Code tab. Describe the complete workflow, including lookups, create-if-missing steps, record creation, and line-item requests.
PARSER sends the AI:
- Your request and current editor code
- The selected document data and metadata
- The available sandbox variables and HTTP methods
- Saved secret names, such as
HUBSPOT_API_KEY
PARSER does not send saved secret values. The AI uses a saved secret by its name, such as secrets.HUBSPOT_API_KEY.
The generated code replaces the code in the editor. It is not saved or run automatically. Review the code, click Run Test, and then click Save code when the result is correct.
Example: Find or create a contact and add invoice lines
const headers = {
Authorization: `Bearer ${secrets.ACCOUNTING_API_KEY}`,
};
const lookup = await axios.get(
`https://api.example.com/contacts?email=${encodeURIComponent(data.Email)}`,
{ headers }
);
let contact = lookup.data[0];
if (!contact) {
const created = await axios.post(
'https://api.example.com/contacts',
{
name: data['Customer Name'],
email: data.Email,
},
{ headers }
);
contact = created.data;
}
const invoiceResponse = await axios.post(
'https://api.example.com/invoices',
{
contact_id: contact.id,
invoice_number: data['Invoice Number'],
},
{ headers }
);
for (const item of data['Line Items'] || []) {
await axios.post(
`https://api.example.com/invoices/${invoiceResponse.data.id}/items`,
item,
{ headers }
);
}
console.log('Created invoice', invoiceResponse.data.id);
return { invoice_id: invoiceResponse.data.id };
Change the URLs, field names, and request bodies to match your destination.
Test the export
1. Select a processed document under Test with a processed document.
2. Click Run Test.
3. Review the status, logs, and returned output.
4. Click Save code when the result is correct.
Tests make real API calls. A test can create or update records in the destination.
When the export runs
The export runs after extraction and post-processing. If the parser uses Reviews & Approvals, the export waits for the required approval.
PARSER does not retry Custom Code Export automatically. Use the document ID as a duplicate-prevention key when the destination supports it.
If the code fails, PARSER records the failure in the document workflow history. The document remains processed, and other configured exports continue.
Limits
- One Custom Code Export per parser
- 30 seconds per execution
- No package installation
- No access to PARSER environment variables, files, or databases
- No automatic retry