# POST /integrations/:id/action

**Resource:** [Integrations](./integrations.md)  
**Scopes:** `integrations:write`  
**Write operation:** yes

Execute an action on an integration (e.g. create invoice in Xero). The integration must be status "active". For xero_create_invoice and xero_create_contact_and_invoice: contact resolution is automatic -- the system finds or creates a Xero contact from the deal's linked customer or CRM contact. You do NOT need to call xero_create_contact first or set customer_id on the deal; xero_create_contact_and_invoice is now a behavioral alias for xero_create_invoice (both auto-resolve the contact). Xero invoice actions (xero_create_invoice, xero_update_invoice) support email_mode ("none" | "xero" | "trustpager"), email_subject, email_body, email_attach_pdf (boolean), email_recipient_source, email_recipient_contact_id, and email_recipient inside params. email_mode "trustpager" sends a branded Postmark email with PDF attached and a Xero pay-now link; requires a default email_config. email_mode "xero" uses Xero native /Email endpoint (no customisation). Default is "none". email_recipient_source controls which contact receives the email: "primary_contact" (deal primary contact, default), "xero_contact" (Xero contact EmailAddress), or "secondary_contact" (a specific CRM contact -- requires email_recipient_contact_id set to a crm_contacts.id). Merge tags supported in subject/body: {{xero.invoice_number}}, {{xero.due_date}}, {{xero.total}}, {{company.name}}, {{contact.first_name}}.

## Parameters

| Name | In | Type | Required | Description |
|------|----|------|----------|-------------|
| `id` | path | uuid | yes | Integration ID |
| `action_type` | body | string | yes | Action type. Xero: xero_create_contact, xero_create_invoice, xero_update_invoice, xero_create_contact_and_invoice (alias for xero_create_invoice -- contact is auto-resolved in both), xero_create_repeating_invoice. Other platforms: slack_send_message, facebook_conversion, portant_generate_document, activecampaign_add_to_automation, calcom_create_booking, calcom_add_guests, zoom_create_meeting. |
| `params` | body | object | yes | Action-specific parameters. For Xero invoice actions: email_mode, email_subject, email_body, email_attach_pdf, email_recipient_source, email_recipient_contact_id, and email_recipient are optional email config fields. For xero_create_repeating_invoice: contact_id (required), schedule_period (required), schedule_unit ("WEEKLY" \| "MONTHLY" \| "YEARLY", required), account_code (required), tax_type (required), approve_for_sending (boolean, default true -- controls whether Xero auto-emails the contact on each invoice cycle), deal_product_ids (array of crm_deal_products.id -- use when creating from the opportunity page modal against a known deal; requires data.deal.id), product_ids (array of crm_products.id -- use from the automation wizard where deal context is resolved at runtime). Provide exactly one of deal_product_ids or product_ids. Usage-Based category products are automatically skipped. |
| `params.email_recipient_source` | body | "primary_contact" | "xero_contact" | "secondary_contact" | no | Who receives the invoice email. "primary_contact" uses the deal primary contact email (default). "xero_contact" uses the EmailAddress on the Xero contact record. "secondary_contact" uses the CRM contact specified by email_recipient_contact_id. Only applies when email_mode is "trustpager" or "xero". |
| `params.email_recipient_contact_id` | body | uuid | no | crm_contacts.id of the secondary contact to email. Required when email_recipient_source is "secondary_contact". Only available via the opportunity-page modal or direct API calls (not the automation wizard). |
| `params.deal_product_ids` | body | uuid[] | no | For xero_create_repeating_invoice: array of crm_deal_products.id to include on the repeating invoice. Use when creating from the opportunity-page modal. Requires a deal ID to be present in the action data context. Mutually exclusive with product_ids. |
| `params.approve_for_sending` | body | boolean | no | For xero_create_repeating_invoice: whether Xero auto-emails the invoice to the contact on each billing cycle. Defaults to true. Set to false to suppress automatic emails (the invoice will still be created in Xero and marked as sent). |

---
Base URL: `https://api.trustpager.com/functions/v1/api/v1` — Auth: `Authorization: Bearer YOUR_API_KEY`