Skip to main content

Agent Settings

An agent's settings decide how its AI behaves: the Main Instructions it follows on every reply, the time zone it reasons in, whether a reply from your team pauses it, when it stops responding and hands a chat to your team, and the hours it answers in. With the Public API you can read and change them from your own systems, for example to keep the instructions in sync with the place your team writes them. Both calls use /v1/agents/{agentId}.

How do I read an agent's settings?​

GET the agent. Besides the basic details the agent list returns, the response carries its settings: the Main Instructions as instructions, the AI handoff as ai_handoff_enabled and ai_handoff_window_minutes, AI auto-disable as ai_stop_enabled and ai_stop_when, the AI working hours as ai_schedule, and comment auto-hide as comment_auto_hide_enabled.

curl https://api.mojeeb.app/v1/agents/YOUR_AGENT_ID \
-H "Authorization: Bearer mk_live_YOUR_KEY_HERE"

GET /v1/agents keeps only the basic details, so get the one agent when you need its settings. The instructions come back exactly as stored, which is what the AI reads: plain text, or HTML when someone last saved them in the dashboard's editor. Every field is in the Get an agent reference.

How do I change the Main Instructions?​

PATCH the agent with instructions. The text replaces the whole of the Main Instructions, and the AI follows it on its next replies, usually within a minute. Mojeeb rebuilds the AI's context in the background only when the text actually changed, so sending the same text again changes nothing.

curl -X PATCH https://api.mojeeb.app/v1/agents/YOUR_AGENT_ID \
-H "Authorization: Bearer mk_live_YOUR_KEY_HERE" \
-H "Content-Type: application/json" \
-d '{ "instructions": "You are the front desk of Acme Clinics.\n\nAnswer in the language the customer writes in.\n\nNever quote prices; offer a call back instead." }'

Send plain text, one rule per line, with a blank line between rules. The dashboard shows lines that have no blank line between them as one paragraph, and saves them that way when someone edits the instructions there. Empty or blank instructions are refused, so a faulty sync can't wipe the agent's standing orders. See Main Instructions for what to write, and the Update an agent's settings reference for the length limit.

How do I change the AI handoff?​

PATCH ai_handoff_enabled, ai_handoff_window_minutes, or both. With the handoff on, a reply from your team in a conversation pauses the AI there, so it doesn't talk over you. The pause lasts the window, counted from your team's last message and extended by each further reply. With it off, the AI keeps answering even right after a person replies.

curl -X PATCH https://api.mojeeb.app/v1/agents/YOUR_AGENT_ID \
-H "Authorization: Bearer mk_live_YOUR_KEY_HERE" \
-H "Content-Type: application/json" \
-d '{ "ai_handoff_enabled": true, "ai_handoff_window_minutes": 30 }'

The window is kept while the handoff is off, so switching it back on restores the same pause. A change applies from your team's next reply: a pause already running ends at its own time, and switching the AI on in that conversation in the dashboard ends it at once. In the dashboard these are the AI handoff switch and the Pause duration under AI Handoff Window; see AI Conversations. The allowed window is in the Update an agent's settings reference.

How do I make the AI stop responding and hand a chat to my team?​

PATCH ai_stop_enabled, ai_stop_when, or both. With ai_stop_enabled on, the AI stops responding in a conversation when a customer's message matches ai_stop_when, or when it spots a bot loop or an attack on the AI. It replies once to say someone from your team will continue, then switches the AI off there.

curl -X PATCH https://api.mojeeb.app/v1/agents/YOUR_AGENT_ID \
-H "Authorization: Bearer mk_live_YOUR_KEY_HERE" \
-H "Content-Type: application/json" \
-d '{ "ai_stop_enabled": true, "ai_stop_when": "When the customer asks to talk to a person or wants a refund." }'

When the AI stops, it also flags the conversation needs_attention, cancels its scheduled follow-ups, and logs the switch with a one-line reason in English for your team; read it with GET on the conversation's ai-switches (see Conversations and Messages). The AI stays off in that conversation until someone switches it back on, in the dashboard or with "ai_enabled": true on the conversation. The bot-loop and attack checks are Mojeeb's own safety rules, and they always apply while ai_stop_enabled is on. An attack is an attempt to make the AI ignore or reveal its instructions, pretend to be someone else, share other customers' data, or send links or code your business wouldn't allow.

ai_stop_when replaces the whole text and is stored without surrounding spaces; an empty string clears it. Sending ai_stop_when without ai_stop_enabled keeps the switch as it is. Switching it on, or changing ai_stop_when while it's on, applies from the agent's next message, and sending what the agent already has changes nothing. It's off by default for every agent. In the dashboard this is the Instruct the AI when to stop responding switch under AI auto-disable; see AI Conversations. The length limit is in the Update an agent's settings reference.

How do I set the hours the AI answers in?​

PATCH ai_schedule with enabled and a list of windows, each with the days it starts on (0 is Sunday, 6 is Saturday) and a from and to time as HH:mm. Outside those hours the AI doesn't answer chats or send follow-ups, exactly as when the AI is off on the channel: the customer's message still reaches your team.

curl -X PATCH https://api.mojeeb.app/v1/agents/YOUR_AGENT_ID \
-H "Authorization: Bearer mk_live_YOUR_KEY_HERE" \
-H "Content-Type: application/json" \
-d '{ "ai_schedule": { "enabled": true, "windows": [ { "days": [0, 1, 2, 3, 4], "from": "09:00", "to": "18:00" } ] } }'

The times are read on the agent's time_zone. A to at or before from runs past midnight into the next day, so 18:00 to 09:00 is a night shift and 00:00 to 00:00 is the whole day. ai_schedule replaces the whole schedule each time; with enabled off the AI answers around the clock and the windows you send are kept. A change applies from the agent's next message. A schedule that can't be saved, such as one switched on with no window, is 422 invalid_ai_schedule. In the dashboard this is AI working hours in the agent's settings; see AI Conversations. The window limit is in the Update an agent's settings reference.

How do I switch comment auto-hide on or off?​

PATCH comment_auto_hide_enabled. It's on by default: the AI hides abusive, spam and similar comments on the agent's Facebook and Instagram accounts. It doesn't change how the AI replies. See Comments and Auto-Hide for the comments themselves and for hiding or showing one.

How do I change the time zone?​

PATCH time_zone with an IANA time zone in Region/City form, such as Asia/Riyadh or Africa/Cairo. It is the clock the agent answers from: opening hours, today and tomorrow, and booking times. An empty string returns the agent to the platform default.

curl -X PATCH https://api.mojeeb.app/v1/agents/YOUR_AGENT_ID \
-H "Authorization: Bearer mk_live_YOUR_KEY_HERE" \
-H "Content-Type: application/json" \
-d '{ "time_zone": "Asia/Riyadh" }'

A name that isn't an IANA zone, such as Cairo or Egypt Standard Time, returns 422 unknown_timezone and nothing changes. The response's time_zone is the zone the agent uses now, including the platform default when you sent an empty string.

How do I rename an agent or change its description?​

PATCH name, description, or both. Each is stored without surrounding spaces, and neither may contain angle brackets. The name can't be blank, and an empty description clears it.

curl -X PATCH https://api.mojeeb.app/v1/agents/YOUR_AGENT_ID \
-H "Authorization: Bearer mk_live_YOUR_KEY_HERE" \
-H "Content-Type: application/json" \
-d '{ "name": "Sales assistant", "description": "Answers product questions and books demos." }'

Your team sees the new name in the dashboard, and the AI sees it in each conversation.

What can't a key change?​

An agent's status, so a key can't delete an agent; its AI model (ai_model and model_provider); its picture (avatar_url); and its language code. Sending any of them with a value returns 422 field_not_writable with param naming the field, and nothing changes. A field sent as null counts as not sent.

{
"error": {
"type": "validation_error",
"code": "field_not_writable",
"message": "An API key can't change an agent's status or delete it; delete agents in the dashboard.",
"param": "status",
"correlation_id": "req_01KQ..."
}
}

Send only the settings you change. A body copied from GET includes language, so sending it back whole is refused. Fields the endpoint doesn't take, such as id or created_at, are ignored. Creating and deleting agents stay in the dashboard. Channel switches and follow-ups have their own endpoints; see Channels and Follow-ups. So does the prompt that decides when the AI saves a lead; see Contacts, Notes and Leads.

Common questions​

Does language change the language the agent replies in?​

No. It is a code saved on the agent, en for nearly every agent, and nothing reads it: the agent replies to each customer in their own language, as its Main Instructions say. That is why a key can't change it. To set the language or dialect, write it into the Main Instructions.

Why do my instructions show as one paragraph in the dashboard?​

The dashboard joins lines that have no blank line between them into one paragraph, and saves them that way the next time someone edits the instructions there. Put a blank line between rules when you write them through the API.

Why do instructions come back as HTML?​

The API returns them exactly as stored. Instructions last saved in the dashboard's editor are stored as its HTML: paragraph, list, bold and italic tags. To decide whether to send, compare your source with what you last sent (for example a hash you keep), not with the returned text.

Does sending the same instructions again rebuild the AI?​

No. Mojeeb compares the text with what is stored and rebuilds the AI's context only when it changed, so a sync job can send the instructions on every run. The comparison is exact: a change in spacing or letter case counts as a change.

Is there a length limit on the instructions?​

Yes, through the API; see the Update an agent's settings reference. The dashboard sets none, so instructions written there can be longer: the API returns them in full, and to write them back through the API, shorten them first.

Does the AI stop when a customer asks for a person?​

Only when ai_stop_when says so. With ai_stop_enabled on and ai_stop_when empty, the AI stops only for bot loops and attacks on the AI, which are Mojeeb's own safety rules. Write the case in your words, such as "When the customer asks to talk to a person or wants a refund.", and the AI hands those chats to your team.

Which conversations does ai_stop_enabled apply to?​

Chats on WhatsApp, Instagram direct messages, Facebook Messenger, the website widget and the dashboard's test chat. It never applies to Facebook or Instagram comments. A message on which the AI runs a tool, such as a booking or a lead capture, never switches the AI off: the AI answers with the tool's result and can stop on a later message.

Does ai_schedule stop comment replies and the test chat?​

No. Outside its working hours the AI stays silent in WhatsApp chats, Instagram direct messages, Facebook Messenger and the website widget, and skips follow-ups. It still answers and hides Facebook and Instagram comments at any hour, and the dashboard's test chat and sendTestChatMessage always answer, so you can try the agent at night.

What happens to messages that arrive outside the working hours?​

They are saved and reach your team in the dashboard like any other message, and the AI doesn't answer them, not even when the hours open again. It answers the customer's next message inside the hours. Your team can reply by hand at any time.

What does 422 no_settings mean?​

The request sent no setting with a value: an empty JSON object, only null values, or only fields the endpoint doesn't take. Send at least one setting.

What if someone edits the agent in the dashboard at the same time?​

The last save wins, as between two dashboard tabs. Get the agent again afterwards if you need to be sure of what is stored.

Can a key create or delete an agent?​

No. Creating and deleting agents stay in the dashboard. Sending status returns 422 field_not_writable, so a key can never delete an agent by accident.

Who can change these settings with a key?​

A key acts with the access of an agent admin on its agents, the access the dashboard asks for to change an agent's settings. A key limited to some agents can change only those; another agent of your organization returns 403 agent_not_authorized. Changing settings needs the agents:write scope, and reading them agents:read; every key holds both today.