> ## 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.

# memories.wait_for_completion

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

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

Wait for an ingestion job to reach a terminal status (`completed`, `failed`, or `partial_success`). Internally polls [`memories.status`](/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

<ParamField path="ingestion_id" type="UUID" required>
  The ingestion job ID to wait on.
</ParamField>

<ParamField path="timeout_seconds" type="integer">
  Maximum time to wait in seconds. Defaults to `300`.
</ParamField>

<ParamField path="poll_interval_seconds" type="integer">
  How often to poll for status in seconds. Defaults to `2`.
</ParamField>

### Returns

`MemoryStatusResponse`: the final status response once the job reaches `completed`, `failed`, or `partial_success`. See [`memories.status`](/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, use [webhooks](/dashboard/webhooks) instead of long-polling.
</Tip>

### Raises

* `TimeoutError`: when the job does not reach a terminal status within `timeout_seconds`.
* `SynapAuthError`: when the API key is missing or invalid.
* `SynapNotFoundError`: when the `ingestion_id` is unknown.

### See also

* [memories.status](/sdk-reference/memories/status)
* [memories.create](/sdk-reference/memories/create)
* [memories.create\_from\_file](/sdk-reference/memories/create-from-file)
