2 min read
The message loop
let conversationId;
async function send(text) {
appendBubble('user', text); // optimistic
const res = await fetch(`${BASE}/support/chat`, {
method: 'POST', headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ conversation_id: conversationId, message: text }),
});
const { reply, conversation_id } = await res.json();
conversationId = conversation_id;
appendBubble('assistant', reply);
}
Handle failures gracefully
If a send fails, mark the user bubble as unsent and offer a retry rather than losing the message. Wrap the call in the standard error handler.
Frequently asked questions
How do I keep context between turns?
Store the conversation_id from the first reply and send it on every subsequent message so the assistant sees the whole thread.
Can I style the chat myself?
Yes — the endpoint is just JSON in, JSON out. The optional widget config gives you branding, but the UI is entirely yours.
Related reading

Quickstart: send a message to the support chat endpoint
POST /public/v1/support/chat powers a conversational support experience. Post the visitor's message with a…
Read →
Quickstart: fetch the support widget configuration
GET /public/v1/support/widget returns the configuration for the embeddable Credicorp support widget. Read the…
Read →
Quickstart: handle Credicorp API error responses
Every Credicorp API error uses the same envelope: { error: { type, code, message, request_id } }. Branch on…
Read →
Quickstart: connect an AI agent to the Credicorp MCP server
POST /public/v1/mcp is a Model Context Protocol endpoint that exposes the public API as agent tools. Point an…
Read →Funding for UK limited companies
Credicorp lends to your company, not to you personally — short-term working capital with no personal guarantee. See what your business could access.