POST
/api/v1/collect
Submit a conversation programmatically β from a script, API client, or any integration that calls an LLM directly and wants to record the exchange.
Identity is derived from page_url (SHA-256 hash), so submitting the same URL again updates rather than duplicates.
β Not for the browser extension β it already uses its own endpoint (/api/v1/conversations) configured in the extension popup. This endpoint is for callers without a browser.
Request body (JSON)
| Field |
Type |
Required |
Description |
page_url | string | yes | Stable URI for the conversation. Use api://<provider>/<conv-id> for API-only calls. |
source_domain | string | yes | e.g. api.anthropic.com, api.openai.com |
qa_pairs | array | yes | List of turns (see sub-fields below). Must have at least one. |
conversation_title | string | no | Human-readable title shown in the UI. |
llm_engine | string | no | Provider name, e.g. anthropic, openai |
llm_version | string | no | Model name, e.g. claude-opus-4, gpt-4o |
conversation_date | ISO datetime | no | Defaults to earliest message_date in the payload. |
metadata | object | no | Arbitrary key-value. Pass {"origin":"api"} to distinguish from browser-collected chats. |
qa_pairs items
| Field |
Type |
Required |
Description |
question | string | yes | User message text. |
answer | string | no | Assistant response text. Omit for pending turns. |
sequence_number | int | no | Turn index (0-based). Auto-assigned if omitted. Used for incremental appends. |
message_date | ISO datetime | no | Timestamp of the turn. Affects daily summary grouping. |
llm_engine / llm_version | string | no | Per-turn model override (e.g. multi-provider conversations). |
Response β 201 Created
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"status": "created", // "created" | "updated" | "duplicate"
"message_count": 4
}
curl example
curl -X POST https://chat.rewire2046.com/api/v1/collect \
-H "X-API-Key: <your-client-key>" \
-H "Content-Type: application/json" \
-d '{
"page_url": "api://anthropic/my-script-conv-001",
"source_domain": "api.anthropic.com",
"conversation_title": "Draft email via Claude API",
"llm_engine": "anthropic",
"llm_version": "claude-opus-4",
"metadata": {"origin": "api"},
"qa_pairs": [
{
"sequence_number": 0,
"question": "Draft a short thank-you email.",
"answer": "Sure! Here is a draft ...",
"message_date": "2026-09-03T10:00:00+08:00"
}
]
}'
Python example
import anthropic, requests, datetime, uuid
client = anthropic.Anthropic()
question = "Explain quantum entanglement in one paragraph."
resp = client.messages.create(
model="claude-opus-4-5",
max_tokens=512,
messages=[{"role": "user", "content": question}],
)
answer = resp.content[0].text
conv_id = str(uuid.uuid4())
now = datetime.datetime.now(datetime.timezone.utc).isoformat()
requests.post(
"https://chat.rewire2046.com/api/v1/collect",
headers={"X-API-Key": "<your-client-key>"},
json={
"page_url": f"api://anthropic/{conv_id}",
"source_domain": "api.anthropic.com",
"conversation_title": question[:60],
"llm_engine": "anthropic",
"llm_version": resp.model,
"metadata": {"origin": "api"},
"qa_pairs": [{
"sequence_number": 0,
"question": question,
"answer": answer,
"message_date": now,
}],
},
).raise_for_status()