Operation contracts and file uploads
Activating operation-contract drafts (a person approves them) and sending multipart file uploads, such as attaching receipts to transactions.
Your AI can call any linked app's API through AMOS with connection_call, and AMOS adds the stored credential on the server. This article covers two advanced cases: saving a reviewed operation contract for an API call you make often, and uploading files.
Operation contracts
An operation contract pins one API call: its exact method, path, request schema, and whether it reads or writes. Your AI can then run it by name with connection_operation_call.
- Your AI proposes contracts with
propose_connection_operations. New contracts are saved as drafts and do nothing yet. You can see them withlist_connection_operationsandinclude_inactive: true. - To turn a draft on, your AI calls
activate_connection_operationswith the contract ids. Activation always waits for a person, so the call returns an approval link. - An owner or admin opens the link (or Settings > Approvals) while signed in and approves it. For a personal connection, the connection's owner approves. An activated contract replaces any older version with the same operation key.
Activation is available on every plan. Drafts don't have their own page yet: they appear in the approval when you activate them.
Path placeholders in a contract, such as {realm_id}, are path parameters that you pass on each call. connection_call fills them in from the stored connection instead.
Uploading files
To upload a file, pass multipart to connection_call instead of body. Each part has a name, an optional content_type and filename, and exactly one of text, json or base64 (use base64 for files). AMOS builds the multipart request itself, so don't set a Content-Type header. You can send up to 10 parts and 20 MiB per request. An upload is sent exactly as given: AMOS doesn't re-encode it or retry it in another format.
QuickBooks attachments. To attach a receipt or other file to a QuickBooks transaction or record, use qbo_attach_file with the entity type (for example Purchase for an expense, Bill or Invoice), the entity's QuickBooks Id, a filename, the content type and the file as base64. AMOS uploads it as a QuickBooks attachment linked to that entity and returns its id. Like any write through a connection, it follows your company's approval policy.