> ## Documentation Index
> Fetch the complete documentation index at: https://tbd-6fc993ce-hypeship-scraperly-link.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](https://kernel.sh/docs/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 kernel = new Kernel();

  const response = await kernel.invocations.follow('id');
  console.log(response);
  ```

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

  kernel = Kernel()

  response = kernel.invocations.follow(id="id")
  print(response)
  ```
</CodeGroup>

### Example

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

```typescript Typescript/Javascript theme={null}
const result = await kernel.invocations.retrieve(invocation.id);
const follow = await kernel.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));
      }
      break;
    } else if (evt.invocation.status === 'failed') {
      console.log('Invocation failed');
      if (evt.invocation.status_reason) {
        console.log('Error:', evt.invocation.status_reason);
      }
      break;
    }
  } else if (evt.event === 'error') {
    console.error('Error:', evt.error.message);
    break;
  }
}
```

## 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 kernel = new Kernel();

  const invocation = await kernel.invocations.retrieve('rr33xuugxj9h0bkf1rdt2bet');
  console.log(invocation.status);
  ```

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

  kernel = Kernel()

  invocation = kernel.invocations.retrieve("rr33xuugxj9h0bkf1rdt2bet")
  print(invocation.status)
  ```
</CodeGroup>
