Skip to main content
REST client

Commerce Memory

The 12 operations under commerce-memory, as typed calls on the generated REST client.

2 min read
View MarkdownEdit on GitHub

Commerce Memory

Available from @codespar/sdk 0.12.0, which is not on npm yet. The published version today is 0.11.0, and it has no cs.api; 0.12.0 is on the main branch of codespar-core. The examples below are not compiled against the installed package for that reason.

Every call below is cs.api reaching one operation of the OpenAPI document this page was generated from; the REST client overview explains request, response, the option bag and the errors. The values are placeholders shaped by the document.

import { CodeSpar } from "@codespar/sdk";

const cs = new CodeSpar({ apiKey: process.env.CODESPAR_API_KEY });

GET /v1/commerce-memory/counterparties

GET/v1/commerce-memory/counterparties
Deprecated

List this project's counterparties (deprecated path)

const result = await cs.api.get("/v1/commerce-memory/counterparties");

Parameters, body and every documented response: GET /v1/commerce-memory/counterparties in the HTTP reference.

POST /v1/commerce-memory/counterparties

POST/v1/commerce-memory/counterparties
Deprecated

Register a counterparty, or merge into the one already there (deprecated path)

const result = await cs.api.post("/v1/commerce-memory/counterparties", {
  body: {
    kind: "supplier",
    name: "Example",
    identifier: "string",
    identifier_kind: "cnpj",
    metadata: {}
  }
});

Parameters, body and every documented response: POST /v1/commerce-memory/counterparties in the HTTP reference.

GET /v1/commerce-memory/counterparties/{id}

GET/v1/commerce-memory/counterparties/{id}
Deprecated

Read one counterparty (deprecated path)

const result = await cs.api.get("/v1/commerce-memory/counterparties/{id}", {
  path: {
    id: "counterpartie_0000000000000000"
  }
});

Parameters, body and every documented response: GET /v1/commerce-memory/counterparties/{id} in the HTTP reference.

GET /v1/commerce-memory/insights/counterparty-summary

GET/v1/commerce-memory/insights/counterparty-summary

Per counterparty rollup over a window

const result = await cs.api.get("/v1/commerce-memory/insights/counterparty-summary");

Parameters, body and every documented response: GET /v1/commerce-memory/insights/counterparty-summary in the HTTP reference.

GET /v1/commerce-memory/insights/negotiation-stats

GET/v1/commerce-memory/insights/negotiation-stats

Negotiation outcomes and average discount, grouped by item

const result = await cs.api.get("/v1/commerce-memory/insights/negotiation-stats");

Parameters, body and every documented response: GET /v1/commerce-memory/insights/negotiation-stats in the HTTP reference.

GET /v1/commerce-memory/insights/top-counterparties

GET/v1/commerce-memory/insights/top-counterparties

Counterparties ranked by payment volume in a window

const result = await cs.api.get("/v1/commerce-memory/insights/top-counterparties");

Parameters, body and every documented response: GET /v1/commerce-memory/insights/top-counterparties in the HTTP reference.

GET /v1/commerce-memory/interactions

GET/v1/commerce-memory/interactions

List recorded interactions

const result = await cs.api.get("/v1/commerce-memory/interactions");

Parameters, body and every documented response: GET /v1/commerce-memory/interactions in the HTTP reference.

POST /v1/commerce-memory/interactions

POST/v1/commerce-memory/interactions

Record a commercial event against a counterparty

const result = await cs.api.post("/v1/commerce-memory/interactions", {
  body: {
    counterparty_id: "counterparty_0000000000000000",
    kind: "quote",
    amount_minor: 1000,
    currency: "BRL",
    occurred_at: "2026-01-15T12:00:00.000Z",
    source: "agent_execute",
    source_ref: "string",
    agent_id: "agt_0000000000000000",
    metadata: {}
  }
});

Parameters, body and every documented response: POST /v1/commerce-memory/interactions in the HTTP reference.

GET /v1/commerce-memory/negotiations

GET/v1/commerce-memory/negotiations

List negotiations

const result = await cs.api.get("/v1/commerce-memory/negotiations");

Parameters, body and every documented response: GET /v1/commerce-memory/negotiations in the HTTP reference.

POST /v1/commerce-memory/negotiations

POST/v1/commerce-memory/negotiations

Record a price negotiation and its outcome

const result = await cs.api.post("/v1/commerce-memory/negotiations", {
  body: {
    counterparty_id: "counterparty_0000000000000000",
    item: "string",
    item_ref: "string",
    initial_price_minor: 1,
    agreed_price_minor: 1,
    currency: "BRL",
    rounds: 0,
    outcome: "agreed",
    agent_id: "agt_0000000000000000",
    started_at: "2026-01-15T12:00:00.000Z",
    closed_at: "2026-01-15T12:00:00.000Z",
    metadata: {}
  }
});

Parameters, body and every documented response: POST /v1/commerce-memory/negotiations in the HTTP reference.

GET /v1/commerce-memory/preferences

GET/v1/commerce-memory/preferences

List preferences

const result = await cs.api.get("/v1/commerce-memory/preferences");

Parameters, body and every documented response: GET /v1/commerce-memory/preferences in the HTTP reference.

POST /v1/commerce-memory/preferences

POST/v1/commerce-memory/preferences

Set or update one preference on a counterparty

const result = await cs.api.post("/v1/commerce-memory/preferences", {
  body: {
    counterparty_id: "counterparty_0000000000000000",
    preference_key: "string",
    confidence: 0,
    source: "explicit",
    metadata: {}
  }
});

Parameters, body and every documented response: POST /v1/commerce-memory/preferences in the HTTP reference.

Commerce Memory | CodeSpar