Emend
API Reference

Playbook Management

Methods for reviewing, searching, retrieving, adding, and deleting user playbooks and agent playbooks.

search_user_playbooksmethod

Search for user playbooks using semantic/text search and advanced filtering.

Info
On authenticated requests, served results are synchronously recorded as evidence before a successful response returns. If recording fails, the search fails; empty results create no evidence batch.
response = client.search_user_playbooks(    query="user satisfaction",    user_id="user_123",    request_id="request_123",    session_id="session_123",    agent_version="v2.1.0",    source="api",    tags=["support"],    top_k=10)
PropType
querystring
user_idstring
request_idstring
session_idstring
agent_versionstring
playbook_namestring
sourcestring
start_timedatetime
end_timedatetime
status_filterlist[Status]
tagsstring[]
top_kinteger
thresholdfloat
enable_reformulationboolean
search_modeSearchMode

Returns SearchUserPlaybookResponse — see Playbook Models.

review_user_playbooksmethod

Re-run the evidence-grounded reviewer over the newest current user playbooks created in an inclusive time window. top_k is applied in newest-first order. For each selected playbook, the server loads the full interaction window recorded by its finalized playbook-extraction run, adds any extra cited interactions retained through consolidation, and restores request grouping. Historical review is therefore not limited by the playbook's smaller cited-evidence subset, the current extraction window size, or the current source filter. Only cited IDs are presented as candidate evidence; the remaining generation-window interactions provide chronology without becoming additional evidence.

The default report mode runs inline and returns decisions without changing storage, while simulating the same newest-first context transitions as apply mode. Because each selected playbook receives a fresh model review, the server automatically gives this endpoint its extended synchronous timeout. A playbook is reported as skip when its finalized generation-window provenance, validated evidence metadata, or a required interaction/request is unavailable, or when its ownership provenance does not match the requesting user; the run then continues. The automatic reviewer that runs immediately after generation separately uses that generation's configured extraction window.

Apply mode
Set report_only=False to apply the decisions. Apply mode is accepted and run in the background — the response returns immediately with a run_id and an empty results list, because a run makes one model call and one write per selected playbook. The run reviews newest-first and commits each completed decision before reviewing the next playbook: accepted rows stay current, rejected rows are archived, and an edit inserts the replacement as current while superseding its incumbent. A later failure stops the run but leaves earlier decisions committed. Applied edits are recorded on the replacement's lineage under the returned run_id.
from datetime import UTC, datetime response = client.review_user_playbooks(    start_time=datetime(2026, 7, 1, tzinfo=UTC),    end_time=datetime(2026, 7, 28, tzinfo=UTC),    top_k=50,    report_only=True,) for result in response.results:    print(result.user_playbook_id, result.decision, result.reason)
PropType
start_timerequireddatetime
end_timerequireddatetime
top_kinteger
report_onlyboolean

See ReviewUserPlaybooksResponse in Playbook Models for result fields and decision details.

search_agent_playbooksmethod

Search for agent playbooks using semantic/text search and advanced filtering. The optional source filter matches provenance: an agent playbook is included when at least one linked source user playbook has that exact source.

response = client.search_agent_playbooks(    query="concise responses",    user_id="user_123",    agent_version="v2.1.0",    source="api",    tags=["tone"],    playbook_status_filter="approved")
PropType
querystring
user_idstring
agent_versionstring
playbook_namestring
sourcestring
start_timedatetime
end_timedatetime
status_filterlist[Status]
tagsstring[]
playbook_status_filterPlaybookStatus
top_kinteger
thresholdfloat
enable_reformulationboolean
search_modeSearchMode

Returns SearchAgentPlaybookResponse — see Playbook Models.

get_user_playbooksmethod

Retrieve user playbook rows containing agent guidance, including entries extracted from interactions and rows created by supported manual or playbook-optimizer workflows.

response = client.get_user_playbooks(    limit=100,    tags=["support"])
PropType
limitinteger
user_playbook_idinteger
user_idstring
request_idstring
querystring
playbook_namestring
agent_versionstring
start_timedatetime
end_timedatetime
status_filterlist[Status]
tagsstring[]

Returns GetUserPlaybooksResponse — see Playbook Models.

add_user_playbookmethod

Add user playbook entries directly to storage.

response = client.add_user_playbook(    user_playbooks=[        {            "agent_version": "v2.1.0",            "request_id": "req_123",            "content": "User expressed satisfaction with response"        }    ])
PropType
user_playbooksrequiredlist[UserPlaybook | dict]
Warning
At least one of content or trigger must be provided.

Returns AddUserPlaybookResponse — see Playbook Models.

add_agent_playbooksmethod

Add agent playbook entries directly to storage.

response = client.add_agent_playbooks(    agent_playbooks=[        {            "agent_version": "v2.1.0",            "content": "Agent should provide more concise responses",            "playbook_status": "approved",            "playbook_metadata": "{}"        }    ])
PropType
agent_playbooksrequiredlist[AgentPlaybook | dict]

Returns AddAgentPlaybookResponse — see Playbook Models.

get_agent_playbooksmethod

Retrieve agent playbook entries.

response = client.get_agent_playbooks(    limit=10,    tags=["tone"])
PropType
limitinteger
agent_playbook_idinteger
querystring
playbook_namestring
agent_versionstring
start_timedatetime
end_timedatetime
status_filterlist[Status]
tagsstring[]
playbook_status_filterPlaybookStatus
force_refreshboolean

Returns GetAgentPlaybooksResponse — see Playbook Models. Cached for 10 minutes; pass force_refresh=True to bypass.

Update Methods

update_user_playbookmethod

Update editable fields of a user playbook in place. Pass only the fields you want to change.

response = client.update_user_playbook(    user_playbook_id=42,    content="Refined playbook content",)
PropType
user_playbook_idrequiredinteger
playbook_namestring
contentstring
triggerstring
rationalestring

Returns: UpdateUserPlaybookResponse with success and message.

update_agent_playbookmethod

Update editable fields of an agent playbook in place. Pass only the fields you want to change.

response = client.update_agent_playbook(    agent_playbook_id=17,    content="Updated guidance")
PropType
agent_playbook_idrequiredinteger
playbook_namestring
contentstring
triggerstring
rationalestring
playbook_statusPlaybookStatus

Returns: UpdateAgentPlaybookResponse with success and message.

update_agent_playbook_statusmethod

Dedicated endpoint for the approval workflow (approve / pending / reject). Use this instead of update_agent_playbook when the only change is the playbook_status — the server enforces tighter validation and writes a smaller change log.

from emend import PlaybookStatus response = client.update_agent_playbook_status(    agent_playbook_id=17,    playbook_status=PlaybookStatus.APPROVED,)
PropType
agent_playbook_idrequiredinteger
playbook_statusrequiredPlaybookStatus

Returns: UpdatePlaybookStatusResponse with success and message.

delete_agent_playbookmethod

Delete an agent playbook by ID.

response = client.delete_agent_playbook(    agent_playbook_id=123,    wait_for_response=True)
PropType
agent_playbook_idrequiredinteger
wait_for_responseboolean
delete_user_playbookmethod

Delete a user playbook by ID.

response = client.delete_user_playbook(    user_playbook_id=456,    wait_for_response=True)
PropType
user_playbook_idrequiredinteger
wait_for_responseboolean

Bulk Delete Operations

delete_agent_playbooks_by_idsmethod

Delete multiple agent playbooks by their IDs.

response = client.delete_agent_playbooks_by_ids(agent_playbook_ids=[1, 2, 3])
PropType
agent_playbook_idsrequiredlist[integer]

Returns: BulkDeleteResponse with success, deleted_count, and message.

delete_user_playbooks_by_idsmethod

Delete multiple user playbooks by their IDs.

response = client.delete_user_playbooks_by_ids(user_playbook_ids=[1, 2, 3])
PropType
user_playbook_idsrequiredlist[integer]

Returns: BulkDeleteResponse with success, deleted_count, and message.

delete_all_playbooksmethod

Delete all playbooks (both user and agent). Cascading variant — wipes both stores.

response = client.delete_all_playbooks()

Returns: BulkDeleteResponse with success, deleted_count, and message.

delete_all_user_playbooksmethod

Delete all user playbooks (user only, not agent).

response = client.delete_all_user_playbooks()

Returns: BulkDeleteResponse with success, deleted_count, and message.

delete_all_agent_playbooksmethod

Delete all agent playbooks (agent only, not user).

response = client.delete_all_agent_playbooks()

Returns: BulkDeleteResponse with success, deleted_count, and message.