> For the complete documentation index, see [llms.txt](https://docs.planetcrust.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.planetcrust.com/sinch/sinch/action-buy-phone-number.md).

# Action: Buy Phone Number

Sinch Operation

<p align="center"><a class="button primary" data-icon="circle-caret-right">Try @Human</a><a class="button primary" data-icon="check">Buy @Human Subscriptions</a><a class="button primary" data-icon="comments">Join @Human Community</a></p>

<figure><img src="https://173051806-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEFQVbo960GBdKqZMghCQ%2Fuploads%2Fgit-blob-6eb88288b969ff5ce560014b0043e5e9daf851e8%2Fsinch.png?alt=media" alt=""><figcaption></figcaption></figure>

<p align="center">The Buy phone number action purchases a virtual or local phone number for voice or SMS use through Sinch’s API.</p>

{% embed url="<https://www.youtube.com/watch?v=CyuUuaBSZzA>" %}

#### Example User Story

I want to buy a local phone number via Sinch for my new branch, so customers can call or text us using a familiar area code.

#### Fields

| Field Name   | Field Type | Required | Description                                                                   |
| ------------ | ---------- | -------- | ----------------------------------------------------------------------------- |
| countryCode  | String     | Yes      | The ISO country code for the phone number (e.g., 'US', 'GB').                 |
| regionCode   | String     | No       | The region or state code within the country (e.g., 'CA' for California).      |
| numberType   | String     | Yes      | The type of phone number (e.g., 'MOBILE', 'LOCAL', 'TOLL\_FREE').             |
| capabilities | String     | Yes      | The capabilities required for the number (e.g., 'SMS', 'VOICE', 'SMS,VOICE'). |

### Related Connections

[Sinch](/sinch/sinch.md)

### Related Automations

Example link

### Code (Apache v2.0): Operation

```
{
  "handle": "buy-phone-number",
  "state": "inDev",
  "meta": {
    "short": "Buy Phone Number",
    "description": "Purchase a phone number from Sinch for SMS or voice services."
  },
  "input": [
    {
      "name": "countryCode",
      "type": "String",
      "required": true,
      "meta": {
        "description": "The ISO country code for the phone number (e.g., 'US', 'GB')."
      }
    },
    {
      "name": "regionCode",
      "type": "String",
      "required": false,
      "meta": {
        "description": "The region or state code within the country (e.g., 'CA' for California)."
      }
    },
    {
      "name": "numberType",
      "type": "String",
      "required": true,
      "meta": {
        "description": "The type of phone number (e.g., 'MOBILE', 'LOCAL', 'TOLL_FREE').",
        "options": ["MOBILE", "LOCAL", "TOLL_FREE"]
      }
    },
    {
      "name": "capabilities",
      "type": "String",
      "required": true,
      "meta": {
        "description": "The capabilities required for the number (e.g., 'SMS', 'VOICE', 'SMS,VOICE').",
        "options": ["SMS", "VOICE", "SMS,VOICE"]
      }
    }
  ],
  "output": [
    {
      "name": "phoneNumber",
      "type": "String",
      "selector": ["phoneNumber"],
      "meta": {
        "description": "The purchased phone number in E.164 format."
      }
    },
    {
      "name": "success",
      "type": "Boolean",
      "selector": ["success"],
      "meta": {
        "description": "Indicates whether the purchase was successful."
      }
    }
  ],
  "steps": [
    {
      "type": "http",
      "http": {
        "method": "POST",
        "path": "/availableNumbers",
        "headers": {
          "Content-Type": "application/json"
        },
        "bodyTemplate": {
          "value": "{\"countryCode\":\"{{countryCode}}\",\"regionCode\":\"{{regionCode}}\",\"type\":\"{{numberType}}\",\"capabilities\":[\"{{capabilities}}\"]}",
          "placeholders": [
            {
              "name": "accessToken",
              "type": "String",
              "description": "The authentication token for Sinch API.",
              "required": true
            },
            {
              "name": "countryCode",
              "type": "String",
              "description": "The ISO country code for the phone number.",
              "required": true
            },
            {
              "name": "regionCode",
              "type": "String",
              "description": "The region or state code within the country.",
              "required": false
            },
            {
              "name": "numberType",
              "type": "String",
              "description": "The type of phone number.",
              "required": true,
              "options": ["MOBILE", "LOCAL", "TOLL_FREE"]
            },
            {
              "name": "capabilities",
              "type": "String",
              "description": "The capabilities required for the number.",
              "required": true,
              "options": ["SMS", "VOICE", "SMS,VOICE"]
            }
          ]
        }
      }
    }
  ]
}
```

<p align="center"><a class="button primary" data-icon="square-caret-right">Try @Human</a><a class="button primary" data-icon="check">Buy @Human Subscription</a><a class="button primary" data-icon="comments">Join @Human Community</a></p>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.planetcrust.com/sinch/sinch/action-buy-phone-number.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
