Topolo Docs Topolo Platform
Open workspace

Create a contact

Add a customer, a supplier, or a business that is both. The name is unique among live contacts in the workspace, so an import that runs twice will not duplicate it.

Outcome

Add a customer, a supplier, or a business that is both. The name is unique among live contacts in the workspace, so an import that runs twice will not duplicate it.

Before you start

  • Verify the intended environment, authenticated identity and specifically approved organization context.
  • The published application permission is contacts:write. Discover the exact granted canonical Books workspace and bind it separately from action input.
  • Approve the actual mutation, accounting inputs and any provider/recipient effects before CLI --confirm or MCP confirm:true. Fixture identifiers and simulated provider responses authorize no live operation.

Discover the target

topolo whoami --json
topolo actions get app_topolo_books.contacts.create --detail --json
topolo resources topolo-books --json
topolo workspaces list topolo-books --json
  • Set BOOKS_WORKSPACE_ID to the exact granted workspace returned by discovery.
  • defaultIncomeAccountId: Resolve this exact identifier through the related published reads for the same organization and workspace; never infer it from a name.
  • defaultExpenseAccountId: Resolve this exact identifier through the related published reads for the same organization and workspace; never infer it from a name.
  • defaultReceivableAccountId: Resolve this exact identifier through the related published reads for the same organization and workspace; never infer it from a name.
  • defaultPayableAccountId: Resolve this exact identifier through the related published reads for the same organization and workspace; never infer it from a name.

Request

POST /api/contacts

Inspect and test this action. Save the reviewed input as payload.json; supply credential/resource context separately.

Input fields

FieldRequiredMeaningSchema and constraints
nameRequiredname{"type":"string","minLength":1,"maxLength":200}
isCustomerOptionalis Customer{"type":"boolean"}
isSupplierOptionalis Supplier{"type":"boolean"}
legalNameOptionallegal Name{"anyOf":[{"type":"string","maxLength":200},{"type":"null"}]}
emailOptionalemail{"anyOf":[{"type":"string","maxLength":320},{"type":"null"}]}
phoneOptionalphone{"anyOf":[{"type":"string","maxLength":60},{"type":"null"}]}
websiteOptionalwebsite{"anyOf":[{"type":"string","maxLength":300},{"type":"null"}]}
taxNumberOptionaltax Number{"anyOf":[{"type":"string","maxLength":60},{"type":"null"}]}
currencyOptionalISO currency code for the record. Amount units and exchange-rate handling must match it.{"anyOf":[{"type":"string","pattern":"^[A-Z]{3}$"},{"type":"null"}]}
paymentTermsDaysOptionalpayment Terms Days{"anyOf":[{"type":"integer","minimum":0,"maximum":365},{"type":"null"}]}
reverseChargeOptionalreverse Charge{"type":"boolean"}
defaultIncomeAccountIdOptionaldefault Income Account Id{"anyOf":[{"type":"string","minLength":1},{"type":"null"}]}
defaultExpenseAccountIdOptionaldefault Expense Account Id{"anyOf":[{"type":"string","minLength":1},{"type":"null"}]}
defaultReceivableAccountIdOptionaldefault Receivable Account Id{"anyOf":[{"type":"string","minLength":1},{"type":"null"}]}
defaultPayableAccountIdOptionaldefault Payable Account Id{"anyOf":[{"type":"string","minLength":1},{"type":"null"}]}
defaultSalesTaxCodeOptionaldefault Sales Tax Code{"anyOf":[{"type":"string","minLength":1,"maxLength":60},{"type":"null"}]}
defaultPurchaseTaxCodeOptionaldefault Purchase Tax Code{"anyOf":[{"type":"string","minLength":1,"maxLength":60},{"type":"null"}]}
addressLine1Optionaladdress Line1{"anyOf":[{"type":"string","maxLength":200},{"type":"null"}]}
addressLine2Optionaladdress Line2{"anyOf":[{"type":"string","maxLength":200},{"type":"null"}]}
cityOptionalcity{"anyOf":[{"type":"string","maxLength":120},{"type":"null"}]}
regionOptionalregion{"anyOf":[{"type":"string","maxLength":120},{"type":"null"}]}
postalCodeOptionalpostal Code{"anyOf":[{"type":"string","maxLength":40},{"type":"null"}]}
countryOptionalcountry{"anyOf":[{"type":"string","maxLength":120},{"type":"null"}]}
notesOptionalnotes{"anyOf":[{"type":"string","maxLength":2000},{"type":"null"}]}

Inspect nested fields and the complete input schema.

Effects

  • Adds one customer or supplier. The name must be free among live contacts in the workspace.

Interpret the response

Read $.contact.id for the returned contact identifier. Empty collections and nullable fields do not discover a target.

Call app_topolo_books.contacts.get with the returned id.

Inspect the success schema. CLI/MCP add their own transport envelope; CLI --detail requests the full result.

Worked examples

Actual Books route handlers and the exported Worker were exercised against five local SQLite D1 concern databases with all committed migrations, the real posting Durable Object and local R2. Route captures use synthetic verified Auth; Worker captures use synthetic Auth transports. Nexus, Brand, Notify, Pay, Mercury and Xero responses are explicitly simulated at the provider transport boundary. Captures prove local request/response behavior and canonical SDK projection, not live bank access, payment movement, email delivery, provider eligibility, tax compliance, encrypted custody, scheduled execution, deployment or production completion. Fixture identities, credentials, addresses and records authorize no live operation.

Run a reviewed request

Save the input from the selected worked example as payload.json. Validate and inspect the plan before calling the action; refused examples demonstrate errors and are not instructions to execute.

CLI:

topolo actions validate app_topolo_books.contacts.create --data @payload.json --json
topolo actions plan app_topolo_books.contacts.create --resource-type workspace --resource-id "$BOOKS_WORKSPACE_ID" --data @payload.json --json
topolo actions call app_topolo_books.contacts.create --resource-type workspace --resource-id "$BOOKS_WORKSPACE_ID" --data @payload.json --confirm --detail --json

MCP tool and arguments for the first successful example:

{
  "tool": "topolo_call_action",
  "arguments": {
    "actionId": "app_topolo_books.contacts.create",
    "input": {
      "name": "Acme Ltd",
      "isCustomer": true,
      "isSupplier": true,
      "paymentTermsDays": 30
    },
    "resourceType": "workspace",
    "resourceId": "<exact granted workspace id>",
    "confirm": true,
    "detail": true
  }
}

Successful response · HTTP 201

Input · payload.json:

{
  "name": "Acme Ltd",
  "isCustomer": true,
  "isSupplier": true,
  "paymentTermsDays": 30
}

Captured response · HTTP 201

{
  "contact": {
    "id": "con_2c50f66c8a214670bdc99d7e82e00fe1",
    "organization_id": "org_contact-route_muvnpccu6",
    "workspace_id": "ws_contact-route_muvnpccu6",
    "name": "Acme Ltd",
    "legal_name": null,
    "is_customer": 1,
    "is_supplier": 1,
    "email": null,
    "phone": null,
    "website": null,
    "tax_number": null,
    "currency": null,
    "payment_terms_days": 30,
    "address_line1": null,
    "address_line2": null,
    "city": null,
    "region": null,
    "postal_code": null,
    "country": null,
    "notes": null,
    "source": "manual",
    "source_contact_id": null,
    "status": "active",
    "created_at": "2026-10-05T19:42:25.233Z",
    "updated_at": "2026-10-05T19:42:25.233Z",
    "reverse_charge": 0,
    "default_income_account_id": null,
    "default_expense_account_id": null,
    "default_receivable_account_id": null,
    "default_payable_account_id": null,
    "default_sales_tax_code": null,
    "default_purchase_tax_code": null
  }
}

HTTP 201. Call app_topolo_books.contacts.get with the returned id.

Refused response · contact_name_taken

Input · payload.json:

{
  "name": "Acme Ltd",
  "isCustomer": true
}

Captured response · HTTP 409

{
  "error": "contact_name_taken",
  "message": "A contact named Acme Ltd already exists in this workspace"
}

HTTP 409. SDK error code contact_name_taken. Read contacts.list and retain the existing exact contact when it represents the intended party. Change the name only for a distinct, authorized new contact.

Refused response · auth_error

Input · payload.json:

{
  "name": "Acme Ltd",
  "isCustomer": true,
  "email": "ap@acme.example",
  "paymentTermsDays": 30,
  "country": "GB"
}

Captured response · HTTP 401

{
  "error": "API key validation failed"
}

HTTP 401. SDK error code auth_error. Authenticate in the intended organization again. Verify whoami and the exact Books application/workspace binding before retrying; do not switch identity to work around a refusal.

Verify the result

  • Call app_topolo_books.contacts.get with the returned id.

Errors and recovery

  • contact_name_taken (HTTP 409): Read contacts.list and retain the existing exact contact when it represents the intended party. Change the name only for a distinct, authorized new contact.
  • auth_error (HTTP 401): Authenticate in the intended organization again. Verify whoami and the exact Books application/workspace binding before retrying; do not switch identity to work around a refusal.

These are observed local refusals. Shared authentication, schema validation and resource authorization can also refuse before the route. Preserve the actual error, details and request id.

Recovery boundary

Archive the contact; it stays readable for any document that already refers to it.

  • Get a contact: Read one contact with its billing details and the accounts it defaults to on an invoice or bill.
  • List contacts: List customers and suppliers. Filter to one role or include archived contacts, search across name, legal name, email, phone, tax number and city, and sort by name, city, country or when the contact was added.
  • Archive a contact: Archive a contact so it is no longer offered on new documents. Contacts are never deleted, because invoices and bills refer to them.

Evidence

Actual Books route handlers and the exported Worker were exercised against five local SQLite D1 concern databases with all committed migrations, the real posting Durable Object and local R2. Route captures use synthetic verified Auth; Worker captures use synthetic Auth transports. Nexus, Brand, Notify, Pay, Mercury and Xero responses are explicitly simulated at the provider transport boundary. Captures prove local request/response behavior and canonical SDK projection, not live bank access, payment movement, email delivery, provider eligibility, tax compliance, encrypted custody, scheduled execution, deployment or production completion. Fixture identities, credentials, addresses and records authorize no live operation.