Commerce Memory
The 12 operations under commerce-memory, as typed calls on the generated REST client.
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
/v1/commerce-memory/counterpartiesList 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
/v1/commerce-memory/counterpartiesRegister 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}
/v1/commerce-memory/counterparties/{id}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
/v1/commerce-memory/insights/counterparty-summaryPer 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
/v1/commerce-memory/insights/negotiation-statsNegotiation 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
/v1/commerce-memory/insights/top-counterpartiesCounterparties 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
/v1/commerce-memory/interactionsList 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
/v1/commerce-memory/interactionsRecord 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
/v1/commerce-memory/negotiationsList 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
/v1/commerce-memory/negotiationsRecord 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
/v1/commerce-memory/preferencesList 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
/v1/commerce-memory/preferencesSet 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.