# Shared Contacts, Notes, Tasks and Calendar APIs — contract 1

Available in JavaScript 0.3.7 and Python/Go/Rust/Java 0.3.0. Requires a deployment with shared APIs enabled. Earlier SDK versions do not contain these resources. Do not put organization server keys in browsers.

## Access and scope

Create a separate shared-app key in Account → API keys. Explicitly select Test or Live, optional workspace, and required operations. The key fixes organization, environment and workspace. Existing keys are not upgraded. Each request also checks the key creator's current membership, app assignment, capabilities and record permissions. Linking does not grant access to either record.

Use the existing gateway origin and Bearer authentication. Reads use GET query parameters; changes use POST JSON. Successful responses are `{ "ok": true, "version": 1, "data": ... }`. Every change requires a stable `requestKey`; updates also require the current `revision`. Persist both the exact input and its key until the outcome is known. Reusing a key with different changes or submitting a stale revision returns 409. Writes are never automatically retried by these SDK resources.

## JavaScript / TypeScript

```ts
import WRNexus from '@wrnexus/sdk';
const client = new WRNexus({apiKey: process.env.WRNEXUS_API_KEY!});
const contact = await client.contacts.create({
  record: {kind: 'person', displayName: 'Integration example'},
  requestKey: crypto.randomUUID(),
});
const note = await client.notes.create({
  record: {title: 'Context', document: {version: 1, blocks: [
    {type: 'paragraph', text: 'Follow up after the meeting.'},
  ]}},
  requestKey: crypto.randomUUID(),
});
const tasks = await client.tasks.list({view: 'my_work', limit: 20});
// Continue with tasks.data.nextCursor and exactly the same filters.
const reminder = await client.calendar.saveReminder({
  reminder: {title: 'Follow up', at: '2099-10-20T10:00:00Z', timezone: 'UTC'},
  requestKey: crypto.randomUUID(),
});
```

Dates and names above are fixtures. For production choose the intended future instant. To link a Note or Task at creation, supply `target: {version:1, appKey:'contacts', recordType:'person', recordId:contact.data.id, scope:{kind:'organization', organizationId:YOUR_ORG_ID, workspaceId:null, environment:'test'}}`. Scope must exactly match the key. The key must grant `contacts.record`, and its creator must be able to read the Contact. Existing records use the `link` operation with the source's current revision. Contact creation itself does not accept a target.

## Other server SDKs

All resources reuse the existing authenticated client and transport configuration:

| Language | Read records | Advanced operation |
| --- | --- | --- |
| Python | `client.contacts.list(limit=20)` | `client.tasks.operation('status', {'id': task_id, 'revision': revision, 'status': 'done', 'requestKey': stable_key})` |
| Go | `client.Contacts.List(ctx, "", "", 20)` | `client.Tasks.Operation(ctx, "status", map[string]any{"id": taskID, "revision": revision, "status": "done", "requestKey": stableKey})` |
| Rust | `client.contacts().list("", "", 20, Default::default())` | `client.tasks().operation("status", serde_json::json!({"id": task_id, "revision": revision, "status": "done", "requestKey": stable_key}), Default::default())` |
| Java | `client.contacts().list("", "", 20)` | `client.tasks().operation("status", Map.of("id", taskId, "revision", revision, "status", "done", "requestKey", stableKey))` |

Python/Go/Rust/Java expose `create`, `get`, `list` and reminder-save helpers plus an explicit operation allowlist. Calendar uses `operation('reminders', ...)` and `operation('reminder', ...)` for reads; generic record helpers apply to Contacts, Notes and Tasks. Java returns JsonNode; Python returns dictionaries; Go and Rust preserve the wire data in their envelope.

## Operation reference

| Resource | GET operations | POST operations |
| --- | --- | --- |
| Contacts | records, record, links | create, update, archive, link, method-add, method-retire |
| Notes | records, record, links, revisions | create, update, archive, link, restore |
| Tasks | records, record, links, checklist, watchers | create, update, archive, link, status, assign, checklist-save, watchers-save, recurrence-save |
| Calendar | reminders, reminder, reminder-jobs | reminder-save, reminder-stop |

Paths are `/<resource>/<operation>` on the API gateway. The generated API reference specifies each operation's allowed fields. Unsupported fields, including actor/scope overrides, are rejected. Lists return resource arrays and `nextCursor`; Calendar uses `items`. A page can be smaller than the requested limit. Calendar reminders are private absolute-time reminders with optional readable `taskId`; recipients, paid delivery policies, invitation capabilities and booking administration remain in their existing workflows.

## Webhooks

Create a separate explicitly scoped shared-app subscription in Account → Webhooks. Topics: `contacts.record.changed`, `notes.record.changed`, `tasks.record.changed`, `calendar.reminder.changed`.

```json
{"id":"notes:EVENT_ID","event":"notes.record.changed","app":"notes","createdAt":"2099-10-19T10:00:00Z","data":{"version":1,"organizationId":"ORG_ID","environment":"test","workspaceId":null,"recordId":"NOTE_ID","revision":2,"action":"notes.note.updated"}}
```

IDs, timestamp and action in this example are illustrative. Verify the existing timestamped HMAC signature against the raw body using the SDK webhook verifier before handling it. Deduplicate the event ID and tolerate retries and out-of-order events. Fetch current content using a separately scoped read key. Payloads contain change metadata only, never Note bodies, contact methods, Task descriptions or linked record contents.

Queueing and delivery both recheck current scope, subscription and creator access. Revocation prevents transmission. Subscriptions do not backfill older events. Inaccessible or purged records may be suppressed rather than sending a tombstone. Native domain event logs connect changes from existing app screens, header modals, Forms automation and AI/Bot tools to the same publisher.
