# Xero Create Contact

Create exactly one contact with PUT /Contacts. Only the typed fields are sent; excluded update fields stay unchanged. No name-based matching or guessed identity. Scope accounting.contacts.

Canonical URL: https://opennodeflow.dev/wiki/reference-xero-contact-create/
JSON reference: https://opennodeflow.dev/wiki/reference-xero-contact-create/index.json
Source snapshot: 2026-10-23

Create exactly one contact with PUT /Contacts. Only the typed fields are sent; excluded update fields stay unchanged. No name-based matching or guessed identity. Scope accounting.contacts.

Inputs: tenantId, idempotencyKey, firstAttemptAt, contact. Outputs: contact, receipt, metadata. exec/next/error are control sockets. Throwing selects an explicitly wired error control route through ONF; data outputs are absent on that path.

Authentication: configure secret **names**, never literal credentials. Access-token mode reads XERO_ACCESS_TOKEN. Managed-refresh mode bootstraps once from XERO_OAUTH_BOOTSTRAP JSON containing access_token, refresh_token, expires_at; XERO_CLIENT_ID / XERO_CLIENT_SECRET hold client values. PKCE omits the secret. Rotated pairs are immediately CAS-persisted in encrypted workspace storage; a 60-second CAS lock serializes refresh. Never use the same refresh grant in different workspaces/namespaces/keys or another app. Do not inspect/export token records into logs. Crash between provider refresh and persistence needs recovery within Xero's documented refresh grace period. No tokens are returned.

Requests use fixed HTTPS Xero hosts, no redirect following, bounded 2 MB response and per-request timeout. Only explicit HTTP loopback mock origins are accepted as overrides. Read HTTP 429/5xx retries are bounded to readRetries (0..2) and Retry-After/maxRetryDelayMs; a longer wait fails with metadata in the safe error message. Network failures and accounting writes are never internally retried. Configure ONF instance retries deliberately; keep write retries disabled. Errors omit raw provider bodies to avoid credential/PII disclosure.

Validation: isolated local mock services only; live tenant consent and account access have not been verified. [Xero accounting requests](https://developer.xero.com/documentation/api/accounting/requests-and-responses/), [OAuth tokens](https://developer.xero.com/documentation/guides/oauth2/token-types/), [tenant connections](https://developer.xero.com/documentation/guides/oauth2/tenants/), [idempotency](https://developer.xero.com/documentation/guides/idempotent-requests/idempotency/), [rate limits](https://developer.xero.com/documentation/best-practices/api-call-efficiencies/rate-limits/).

WRITE: allowWrites=true is required. Supply a stable domain idempotencyKey (1..128 chars) and the ORIGINAL firstAttemptAt. The node rejects firstAttemptAt older than five minutes; Xero retains keys for six minutes. Internal HTTP retries are zero. Reconcile uncertain completion through read operations before deliberate replay. Never generate a new key merely to bypass uncertainty. Xero applies business validation and tenant permissions.

## Audited socket contract (21 October 2026)

Inputs:
- `tenantId`: `string`; required.
- `idempotencyKey`: `string`; required.
- `firstAttemptAt`: `string`; required.
- `contact`: `@xero.contactWrite`; required.

Outputs:
- `contact`: `@xero.contact`; required.
- `receipt`: `@xero.writeReceipt`; required.
- `metadata`: `@xero.metadata`; required.

Configuration:
- `authMode`: string; default "accessToken". accessToken reads a current bearer secret; managedRefresh keeps rotating tokens encrypted in workspace storage.
- `accessTokenSecret`: string; default "XERO_ACCESS_TOKEN"
- `bootstrapTokenSecret`: string; default "XERO_OAUTH_BOOTSTRAP". JSON secret containing access_token, refresh_token and expires_at (ISO time). Used only when the storage key does not exist.
- `clientIdSecret`: string; default "XERO_CLIENT_ID"
- `clientSecretSecret`: string; default "XERO_CLIENT_SECRET"
- `pkce`: boolean; default false
- `tokenNamespace`: string; default "integration.xero.oauth"
- `tokenKey`: string; default "default"
- `mockBaseUrl`: string; default "". Tests only: HTTP loopback origin. Production endpoints cannot be overridden.
- `requestTimeoutMs`: integer; default 10000
- `readRetries`: integer; default 1
- `maxRetryDelayMs`: integer; default 2000
- `allowWrites`: boolean; default false. Explicitly permit this accounting write. Keep ONF automatic retries disabled.

Known provider records and list elements have structural schemas. Explicit dynamic payloads, selected query results and provider extensions retain the recursive JSON Value vocabulary; they do not imply a known provider entity. Null is distinct from omission. Runtime validates the exact selected immutable type version; reading newer documentation never repins existing graphs. This audit used synthetic fixtures/local mocks and does not establish live provider authorization or delivery.

## Catalog identity

| Field | Value |
| --- | --- |
| Source key | `xero.contact.create` |
| Kind | node |
| Family | xero |
| Pack | See library discovery |

[Integration guide](/wiki/integration-xero/) · [Browse the catalog](/wiki/integration-catalog/)

## Inputs

| Socket ID | Label | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `exec` | exec | control | No |  |
| `tenantId` | tenantId | string | Yes |  |
| `idempotencyKey` | idempotencyKey | string | Yes |  |
| `firstAttemptAt` | firstAttemptAt | string | Yes |  |
| `contact` | contact | @xero.contactWrite v1 | Yes |  |

## Outputs

| Socket ID | Label | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `contact` | contact | @xero.contact v1 | Yes |  |
| `receipt` | receipt | @xero.writeReceipt v1 | Yes |  |
| `metadata` | metadata | @xero.metadata v1 | Yes |  |
| `next` | next | control | No |  |
| `error` | error | control | No |  |

## Configuration schema


```json
{
  "type": "object",
  "properties": {
    "authMode": {
      "type": "string",
      "enum": [
        "accessToken",
        "managedRefresh"
      ],
      "default": "accessToken",
      "description": "accessToken reads a current bearer secret; managedRefresh keeps rotating tokens encrypted in workspace storage."
    },
    "accessTokenSecret": {
      "type": "string",
      "default": "XERO_ACCESS_TOKEN"
    },
    "bootstrapTokenSecret": {
      "type": "string",
      "default": "XERO_OAUTH_BOOTSTRAP",
      "description": "JSON secret containing access_token, refresh_token and expires_at (ISO time). Used only when the storage key does not exist."
    },
    "clientIdSecret": {
      "type": "string",
      "default": "XERO_CLIENT_ID"
    },
    "clientSecretSecret": {
      "type": "string",
      "default": "XERO_CLIENT_SECRET"
    },
    "pkce": {
      "type": "boolean",
      "default": false
    },
    "tokenNamespace": {
      "type": "string",
      "default": "integration.xero.oauth",
      "minLength": 1
    },
    "tokenKey": {
      "type": "string",
      "default": "default",
      "minLength": 1
    },
    "mockBaseUrl": {
      "type": "string",
      "default": "",
      "description": "Tests only: HTTP loopback origin. Production endpoints cannot be overridden."
    },
    "requestTimeoutMs": {
      "type": "integer",
      "minimum": 100,
      "maximum": 30000,
      "default": 10000
    },
    "readRetries": {
      "type": "integer",
      "minimum": 0,
      "maximum": 2,
      "default": 1
    },
    "maxRetryDelayMs": {
      "type": "integer",
      "minimum": 0,
      "maximum": 10000,
      "default": 2000
    },
    "allowWrites": {
      "type": "boolean",
      "default": false,
      "description": "Explicitly permit this accounting write. Keep ONF automatic retries disabled."
    }
  },
  "required": [],
  "additionalProperties": false
}
```





## Source and installed versions

This reference describes the maintained source catalog snapshot, not a live export of your installation. Published definitions use immutable versions; installed graphs retain their exact pins. Discover and read the installed definition and selected version before wiring it. See [versioning](/wiki/versioning/), [connections](/wiki/connections/) and [integration setup](/wiki/integration-setup/).

---

## Documentation provenance

- `../OpenNodeFlow-Library/work/catalog-all.mjs`
- `../OpenNodeFlow-Library/work/azure-pack-consolidation-20261022/catalog-policy.mjs`
- `../OpenNodeFlow-Library/work/developer-packs-20261022/catalog.mjs`
- `shared/seed.ts`
- `shared/storage-library.ts`
- `shared/variable-library.ts`
- `shared/control-flow.ts`
- `shared/remote-routes.ts`
- `server/runtime-library.ts`
- `shared/error-library.ts`
- `shared/storage-model.ts`
- `shared/builtin-documentation.ts`

This page describes maintained source, not a live inventory or an authorization to perform actions.
