> ## Documentation Index
> Fetch the complete documentation index at: https://docs.maximem.ai/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Maximem Synap is a managed memory layer for AI agents: it ingests conversations and documents, extracts structured memory, and returns scoped context to the agent at retrieval time.
> The Python and JavaScript/TypeScript SDKs are the supported way to use Synap. Write integration code with SDK calls, not raw HTTP requests.
> Start with the Quickstart: https://docs.maximem.ai/getting-started/quickstart.md. Every SDK method is documented in the SDK reference: https://docs.maximem.ai/sdk-reference/overview.md.
> For requests about adding Vity memory to OpenClaw, Hermes, an MCP client, or a browser, start with the Vity Quickstart: https://docs.maximem.ai/vity/quickstart.md.

# memories.wait_for_completion

> Block until an ingestion job reaches a terminal status, or raise on timeout.

```python Python theme={null}
await sdk.memories.wait_for_completion(ingestion_id, timeout_seconds=300, poll_interval_seconds=2)
```

```typescript TypeScript theme={null}
await sdk.memories.wait_for_completion(ingestionId: string, options?: WaitOptions)
```

Wait for an ingestion job to reach a terminal status (`completed`, `failed`, or `partial_success`). Internally polls [`memories.status`](https://docs.maximem.ai/sdk-reference/memories/status) at the requested interval and returns the final status response. Useful for scripts and tests where you need a synchronous result before moving on.

### Parameters

**ingestion\_id** `UUID` *required*

The ingestion job ID to wait on.

**timeout\_seconds** `integer`

Maximum time to wait in seconds. Defaults to `300`.

**poll\_interval\_seconds** `integer`

How often to poll for status in seconds. Defaults to `2`.

### Returns

`MemoryStatusResponse`: the final status response once the job reaches `completed`, `failed`, or `partial_success`. See [`memories.status`](https://docs.maximem.ai/sdk-reference/memories/status) for the full field list.

### Example

```python theme={null}
from maximem_synap import MaximemSynapSDK

sdk = MaximemSynapSDK(api_key="synap_your_key_here")
await sdk.initialize()

result = await sdk.memories.create(
    document="User prefers email communication.",
    document_type="ai-chat-conversation",
    user_id="user_789",
    customer_id="cust_456",
    mode="long-range",
)

final = await sdk.memories.wait_for_completion(
    result.ingestion_id,
    timeout_seconds=120,
    poll_interval_seconds=3,
)
print(final.status)         # "completed"
print(final.memory_ids)     # IDs ready to fetch
```

> [!TIP]
>
> Prefer this helper over your own polling loop in scripts and integration tests. In production applications, poll [`memories.status`](https://docs.maximem.ai/sdk-reference/memories/status) at an interval that suits you, or skip the wait and let extraction finish in the background; you do not need `wait_for_completion` to use a memory later.

### Raises

* `TimeoutError`: when the job does not reach a terminal status within `timeout_seconds`.
* `AuthenticationError`: when the API key is missing or invalid.
* `ContextNotFoundError`: when the `ingestion_id` is unknown (HTTP 404).

### See also

* [memories.status](https://docs.maximem.ai/sdk-reference/memories/status.md)
* [memories.create](https://docs.maximem.ai/sdk-reference/memories/create.md)
* [memories.create\_from\_file](https://docs.maximem.ai/sdk-reference/memories/create-from-file.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.