Skip to Content
AgentsMemory Writes

Memory Writes

The write primitive. Append a typed memory entry to a customer’s ledger. Three types: decision, action, observation. Idempotent when you supply idempotency_key. Backed by MCP tool write_memory.

The ledger feeds the next GET /v1/context call as recent_decisions plus internal signal computation. This is how agents share state across sessions, runs, and even across separate agents.

Request

POST /v1/memory

FieldTypeNotes
customerstring, requiredCustomer ID. Get one from /v1/context.
typeenum, requireddecision, action, or observation.
agentstring, requiredAgent identifier you control. Pick a stable slug.
payloadobject, requiredFree-form. Recommend keeping under 4 KB.
idempotency_keystring, optionalSame key + same payload returns the original entry instead of creating a new one.

Required scope: memory:write.

When to use which type

  • decision. The agent picked a path. (“escalate_to_human”, “send_followup_email”)
  • action. The agent did a thing in the world. (“sent_email”, “created_ticket”, “placed_call”)
  • observation. The agent noticed something worth recording but did not act. (“customer_mentioned_competitor”)

Examples

curl

curl https://api.waypath.app/v1/memory \ -H "X-API-Key: wp_live_..." \ -H "Content-Type: application/json" \ -d '{ "customer": "cus_8af2", "type": "decision", "agent": "support_v2", "payload": { "action": "escalate_to_human", "reason": "customer_frustrated", "confidence": 0.86 }, "idempotency_key": "esc-1284-v2" }'

node-fetch

const res = await fetch('https://api.waypath.app/v1/memory', { method: 'POST', headers: { 'X-API-Key': process.env.WAYPATH_API_KEY!, 'Content-Type': 'application/json', }, body: JSON.stringify({ customer: 'cus_8af2', type: 'decision', agent: 'support_v2', payload: { action: 'escalate_to_human', reason: 'customer_frustrated' }, idempotency_key: 'esc-1284-v2', }), }) const entry = await res.json()

python

import os, requests entry = requests.post( 'https://api.waypath.app/v1/memory', headers={'X-API-Key': os.environ['WAYPATH_API_KEY']}, json={ 'customer': 'cus_8af2', 'type': 'decision', 'agent': 'support_v2', 'payload': {'action': 'escalate_to_human', 'reason': 'customer_frustrated'}, 'idempotency_key': 'esc-1284-v2', }, timeout=5, ).json()

MCP

await mcp.tools.write_memory({ customer: 'cus_8af2', type: 'decision', agent: 'support_v2', payload: { action: 'escalate_to_human' }, idempotency_key: 'esc-1284-v2', })

Response

{ "id": "mem_a91b", "customer": "cus_8af2", "type": "decision", "ts": "2026-04-29T18:14:32Z", "idempotency_key": "esc-1284-v2" }

Idempotency

The pattern is: build a deterministic key from the inputs that should be safe to replay. Examples:

  • A ticket escalation: esc-{ticketId}-{version}
  • A scheduled outbound: out-{customerId}-{cadenceWindow}
  • A backfill row: import-{sourceSystem}-{rowId}

Replays with the SAME idempotency_key and SAME payload return the original entry with status 201 and the original ts. Replays with the same key but DIFFERENT payload return 409 idempotency_conflict. Pick a fresh key for genuinely new writes.

Errors

StatusCodeCause
400invalid_payloadMissing required field, or type not in enum.
401unauthenticatedMissing or invalid X-API-Key.
403forbidden_scopeKey lacks memory:write.
404not_foundCustomer ID does not exist.
409idempotency_conflictSame idempotency_key, different payload.
429rate_limitedPer-key cap. Honor Retry-After.

See also


SYNC · OK© 2026 WAYPATHBUILD · D-03SOC2 · IN PROGRESSWAYPATH.APP