***

title: extractSipUsername
slug: /reference/typescript/agents/agent-base/extract-sip-username
description: Extract the SIP username from a request body's call.to field.
max-toc-depth: 3
---------------------

For a complete index of all SignalWire documentation pages, fetch https://signalwire.com/docs/llms.txt

Static method that extracts the SIP username from a request body's `call.to` field.
Strips the `sip:` or `sips:` protocol prefix and the `@domain` suffix, returning
just the username portion.

## **Parameters**

<ParamField path="requestBody" type={"Record<string, unknown>"} required={true} toc={true}>
  The parsed request body containing call information. Expected to have a `call.to`
  field in SIP URI format (e.g., `"sip:helpdesk@example.com"`).
</ParamField>

## **Returns**

`string | null` -- The extracted SIP username, or `null` if not found.

## **Example**

```typescript {3}
import { AgentBase } from '@signalwire/sdk';

const username = AgentBase.extractSipUsername({
  call: { to: 'sip:helpdesk@example.com' },
});
console.log(username); // "helpdesk"

const noMatch = AgentBase.extractSipUsername({});
console.log(noMatch); // null
```