Answer an email ask
Sends the visitor’s answer to the agent’s ask for their email: the address, or null for “Not now”. An address is saved on the visitor, unverified, and reaches your tools as visitor.email. Either answer wakes the agent to carry on.
POST
/email-askAuthorization
AuthorizationBearer token · headerrequiredA MEDIAN_KEY from Settings under API. It starts with `median_key_` and stays on your server. The tool endpoint routes also accept an OAuth access token (`median_oat_`) from `median login` or an MCP client, acting as the person who approved it. The messaging routes accept only a Median key.
Request body
requiredapplication/jsonsessionstringrequiredThe visitor's session token.
min length 8 · max length 128
conversationIdstringrequiredThe thread's `conversationId`.
emailstring | nullrequiredThe address they gave, or `null` for "Not now".
Responses
200The answer was saved, and the agent carries on.
okboolean400`invalid_json`: the body is not a JSON object. `invalid_request`: `session` or `conversationId` is not a string, or `email` is neither a string nor null. `invalid_session`: the session is not 8 to 128 characters. `invalid_email`: the address is not an email. The ask stays open.
errorobjectrequiredShow propertiesHide properties
codestringrequiredBranch on this rather than on the message.
messagestringrequired401`missing_api_key`: no bearer token. `invalid_api_key`: the key matches no organization or was revoked. `publishable_key`: a `median_pk_` key was sent. An OAuth access token is refused here with `invalid_api_key`.
errorobjectrequiredShow propertiesHide properties
codestringrequiredBranch on this rather than on the message.
messagestringrequired409`no_open_ask`: the agent is not waiting for an email in this conversation. It was answered already, the conversation ended, or it is not this session's.
errorobjectrequiredShow propertiesHide properties
codestringrequiredBranch on this rather than on the message.
messagestringrequired429The organization's API allowance for this class of request is used up. Wait the `Retry-After` header's seconds. Limits depend on the plan. See [rate limits](/api/errors-and-limits#rate-limits).
errorobjectrequiredShow propertiesHide properties
codestringrequiredBranch on this rather than on the message.
messagestringrequiredRequest
curl -X POST "https://api.median.sh/v1/email-ask" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"session": "user_42",
"conversationId": "js7...",
"email": "ada@example.com"
}'const response = await fetch("https://api.median.sh/v1/email-ask", {
method: "POST",
headers: {
"Authorization": "Bearer YOUR_TOKEN",
"Content-Type": "application/json"
},
body: JSON.stringify({
"session": "user_42",
"conversationId": "js7...",
"email": "ada@example.com"
})
});Response
{
"ok": true
}{
"error": {
"code": "invalid_email",
"message": "That doesn't look like an email address. Check it and try again."
}
}{
"error": {
"code": "invalid_api_key",
"message": "That Median key does not match any organization. Copy the median_key_ key again from Settings under API."
}
}{
"error": {
"code": "no_open_ask",
"message": "The agent is not waiting for an email in this conversation. Read the thread again for its current state."
}
}{
"error": {
"code": "rate_limited",
"message": "Your organization's API allowance is temporarily full. Please retry shortly."
}
}