> ## Documentation Index
> Fetch the complete documentation index at: https://tbd-6fc993ce-mason-add-copy-page-to-context-menu.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Status

Once you've [deployed](/apps/deploy) an app and invoked it, you can monitor its status using streaming for real-time updates or polling for periodic checks.

<Info>
  An invocation ends once its code execution finishes.
</Info>

## Streaming Status Updates

For real-time status monitoring, use `follow` to [stream invocation events](/api-reference/invocations/stream-invocation-events-via-sse). This provides immediate updates as your invocation progresses and is more efficient than polling.

<CodeGroup>
  ```typescript Typescript/Javascript theme={null}
  import Kernel from '@onkernel/sdk';

  const client = new Kernel({
    apiKey: 'My API Key',
  });

  const response = await client.invocations.follow('id');

  console.log(response);
  ```

  ```python Python theme={null}
  from kernel import Kernel

  client = Kernel(
      api_key="My API Key",
  )
  response = client.invocations.follow(
      id="id",
  )
  print(response)
  ```
</CodeGroup>

### Example

Here's an example showing how to handle streaming status updates:

```javascript theme={null}
const result = await client.invocations.retrieve(invocation.id);

const follow = await client.invocations.follow(result.id);
for await (const evt of follow) {
  if (evt.event === 'invocation_state') {
    console.log(`Status: ${evt.invocation.status}`);

    if (evt.invocation.status === 'succeeded') {
      console.log('✅ Invocation completed successfully!');
      if (evt.invocation.output) {
        console.log('Result:', JSON.parse(evt.invocation.output));
      }
    } else if (evt.invocation.status === 'failed') {
      console.log('❌ Invocation failed');
      if (evt.invocation.status_reason) {
        console.log('Error:', evt.invocation.status_reason);
      }
    }
  } else if (evt.event === 'error') {
    console.error('🚨 Error:', evt.error.message);
  }
}

console.log('✅ Invocation successful!');
console.log('Invocation result:', JSON.stringify(result, null, 2));
```

## Polling Status Updates

Alternatively, you can poll the status endpoint using `retrieve` to check the invocation status periodically.

<CodeGroup>
  ```typescript Typescript/Javascript theme={null}
  import Kernel from '@onkernel/sdk';

  const client = new Kernel({
    apiKey: 'My API Key',
  });

  const invocation = await client.invocations.retrieve('rr33xuugxj9h0bkf1rdt2bet');

  console.log(invocation.id);
  ```

  ```python Python theme={null}
  from kernel import Kernel

  client = Kernel(
      api_key="My API Key",
  )
  invocation = client.invocations.retrieve(
      "rr33xuugxj9h0bkf1rdt2bet",
  )
  print(invocation.id)
  ```
</CodeGroup>
