# Get phone number data

**Step 1: Prepare Your Request**

* **Endpoint:** `/phone-number`
* **Method:** `POST`
* **URL:** `https://api.talkstackai.com/phone-number`
* **Headers:** Include `Content-Type: application/json`.
* **Authorization:** Bearer token or x-api-key in headers

**Step 2: Construct Request Body**

You can get phone numbers using phoneNumberId, agentId, and projectId. You can only use one of these in each request if more than one are passed then the precedence order is: \
**phoneNumberId -> agentId -> projectId**

* `phoneNumberId`: This is the ID of the phone number you are inquiring about..
* `agentId`: This is the agent ID linked to the phone number you are inquiring about.
* `projectId`: This is the project ID linked to the phone number(s) you are inquiring about.

**Step 3: Send the Request**

Use your preferred HTTP client to send the POST request with the above JSON body.

**Step 4: Handle the Response**

The response will provide detailed information about the phone number associated with the given identifier.

**Success Response:**

* **Status Code:** `200 OK`
* **Body:**&#x20;

```
{
    "message": "Phone number details fetched successfully.",
    "status": "error",
    "data": {
        "e164": "+14152148508",
        "id": "3189fbff-f9fa-4920-b95c-63387b1204a4",
        "status": "AVAILABLE",
        "projectId": "94f53ecd-ec99-42fc-bc69-e79468550af2",
        "agentId": "232ac42a-2ea0-4276-a5d8-43c8c9f7b857"
    }
}
```

* Confirm that the `projectId` is correctly included in the request body.
* Ensure that the `agentId` is valid and corresponds to the phone number searched for.
* Contact our support team for further assistance in case of persistent issues or errors.

**Troubleshooting**

* `400 Bad Request`: If the identifier is missing in the request.
* `404 Not Found`: If the phone number is not found.
* `500 Internal Server Error`: For errors in fetching phone number details.


---

# Agent Instructions: 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:

```
GET https://docs.talkstack.ai/phone-number/get-phone-number-data.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
