# TypeScript SDK (/docs/guides/typescript-sdk)

## Before You Begin [#before-you-begin]

Obtain a [brand-scoped API key](/docs/authentication), configure `SMOBI_API_KEY` in your server environment, and confirm that your brand has a messaging sender. Use a phone number you control for these examples.

## Install [#install]

```bash
npm install smobi-sdk@0.3.11
```

This guide is checked against version `0.3.11`. Its generated types require `content.rcs`, so the example supplies RCS text with an SMS fallback. For SMS-only sends, use the [HTTP quickstart](/docs/quickstart).

## Create a Client and Send a Message [#create-a-client-and-send-a-message]

```typescript
import { SmobiClient } from 'smobi-sdk';

const apiKey = process.env.SMOBI_API_KEY;
if (!apiKey) throw new Error('SMOBI_API_KEY is required');

const client = new SmobiClient({ apiKey });

const result = await client.messaging.sendMessage(
  {
    clientRef: 'quickstart-001',
    recipientPhoneNumber: '15552223333',
    content: {
      rcs: { content: { type: 'TEXT', content: 'Hello from Smobi!' } },
      sms: { content: 'Hello from Smobi!' },
    },
  },
  { maxRetries: 0 },
);

console.log(result.smobiMessageId);
```

Run this on your backend and replace the recipient with your own phone number. The example disables automatic retries for a send so an ambiguous failure is not blindly resubmitted.

## Run a Workflow [#run-a-workflow]

```typescript
const execution = await client.workflows.executeSingle(
  'YOUR_WORKFLOW_DEFINITION_ID',
  '15552223333',
  { variables: { customerName: 'Alex' } },
  { maxRetries: 0 },
);
```

## Supported Resources and Request Options [#supported-resources-and-request-options]

The SDK exposes `messaging` and `workflows` resources. For contact management, use the [Contacts HTTP API](/docs/guides/contacts).

Request options include `timeoutInSeconds`, `maxRetries`, and `abortSignal`. Keep a clear retry policy for message sends and workflow executions to avoid duplicate messages or executions after an uncertain response.

Consult the [API Reference](/docs/api) for request and response schemas. Review API compatibility and test your integration before upgrading the SDK.

## Related Resources [#related-resources]

- [API Reference](/docs/api)
- [Troubleshooting](/docs/troubleshooting)
