# Fax Numbers

## List Numbers

GET `/fax_numbers` — Returns all fax numbers provisioned for your account.

#### cURL

```bash
curl -s -H "Authorization: Bearer sk_test_..." "https://api.medsender.com/api/v2/fax_numbers" | jq
```

#### Node

```javascript
const API_BASE='https://api.medsender.com/api/v2';
const API_KEY='sk_test_...';
const res=await fetch(`${API_BASE}/fax_numbers`,{headers:{Authorization:`Bearer ${API_KEY}`}});
console.log(await res.json());
```

#### TypeScript

```typescript
const API_BASE: string='https://api.medsender.com/api/v2';
const API_KEY: string='sk_test_...';
const res = await fetch(`${API_BASE}/fax_numbers`, { headers: { Authorization: `Bearer ${API_KEY}` } });
console.log(await res.json());
```

#### Python

```python
import requests
API_BASE='https://api.medsender.com/api/v2'
API_KEY='sk_test_...'
r=requests.get(f"{API_BASE}/fax_numbers", headers={'Authorization':f'Bearer {API_KEY}'})
print(r.json())
```

#### Ruby

```ruby
require 'net/http'
require 'uri'
uri = URI.parse('https://api.medsender.com/api/v2/fax_numbers')
req = Net::HTTP::Get.new(uri)
req['Authorization'] = 'Bearer sk_test_...'
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true){|http| http.request(req)}
puts res.body
```

#### PHP

```php
<?php
$ch = curl_init();
curl_setopt_array($ch, [
  CURLOPT_URL => 'https://api.medsender.com/api/v2/fax_numbers',
  CURLOPT_HTTPHEADER => ['Authorization: Bearer sk_test_...'],
  CURLOPT_RETURNTRANSFER => true
]);
$res = curl_exec($ch);
echo $res;
```

#### Java

```java
import java.net.http.*;
import java.net.URI;
public class ListNumbers {
  public static void main(String[] args) throws Exception {
    var client = HttpClient.newHttpClient();
    var req = HttpRequest.newBuilder()
      .uri(URI.create("https://api.medsender.com/api/v2/fax_numbers"))
      .header("Authorization","Bearer sk_test_...")
      .GET()
      .build();
    var res = client.send(req, HttpResponse.BodyHandlers.ofString());
    System.out.println(res.body());
  }
}
```

#### C#

```csharp
using System;
using System.Net.Http;
var url = "https://api.medsender.com/api/v2/fax_numbers";
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization","Bearer sk_test_...");
var res = await client.GetAsync(url);
Console.WriteLine(await res.Content.ReadAsStringAsync());
```

Response

```json
{
  "fax_numbers": [
    {
      "id": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
      "number": "+15550100001",
      "callback_url": "https://example.com/webhooks/fax",
      "created_at": "2025-01-15T10:30:00.000Z",
      "client": null,
      "uri": "https://api.medsender.com/api/v2/fax_numbers/f47ac10b-58cc-4372-a567-0e02b2c3d479"
    }
  ]
}
```

Response Fields

| Field | Description |
| --- | --- |
| id | Unique identifier (UUID) for this fax number |
| number | The fax number in E.164 format (e.g. +15550100001) |
| callback_url | Webhook URL for incoming fax notifications |
| created_at | When the number was provisioned (ISO 8601) |
| client | Client object if assigned, otherwise null |
| uri | API endpoint URL for this fax number |

## Provision Number

POST `/fax_numbers` — Provisions a new fax number in the specified area code.

Request Parameters (JSON body)

| Parameter | Required | Description |
| --- | --- | --- |
| fax_number.area_code | Yes | 3-digit US area code (e.g. "415", "212") |
| fax_number.callback_url | No | Webhook URL for incoming fax notifications |
| fax_number.client_id | No | Client ID to assign this number to |

#### cURL

```bash
export API_BASE="https://api.medsender.com/api/v2"
export API_KEY="sk_test_..."

curl -s -X POST -H "Authorization: Bearer $API_KEY" -H "Content-Type: application/json" -d '{"fax_number":{"area_code":"415"}}' "$API_BASE/fax_numbers" | jq
```

#### Node

```javascript
const API_BASE='https://api.medsender.com/api/v2';
const API_KEY='sk_test_...';
const res=await fetch(`${API_BASE}/fax_numbers`,{method:'POST',headers:{Authorization:`Bearer ${API_KEY}`,'Content-Type':'application/json'},body:JSON.stringify({fax_number:{area_code:'415'}})});
console.log(await res.json());
```

#### TypeScript

```typescript
const API_BASE: string='https://api.medsender.com/api/v2';
const API_KEY: string='sk_test_...';
const res = await fetch(`${API_BASE}/fax_numbers`, { method:'POST', headers:{ Authorization: `Bearer ${API_KEY}`, 'Content-Type':'application/json' }, body: JSON.stringify({ fax_number: { area_code: '415' } }) });
console.log(await res.json());
```

#### Python

```python
import requests, json
API_BASE='https://api.medsender.com/api/v2'
API_KEY='sk_test_...'
body={'fax_number':{'area_code':'415'}}
r=requests.post(f"{API_BASE}/fax_numbers", headers={'Authorization':f'Bearer {API_KEY}','Content-Type':'application/json'}, data=json.dumps(body))
print(r.json())
```

#### Ruby

```ruby
require 'net/http'
require 'uri'
uri = URI.parse('https://api.medsender.com/api/v2/fax_numbers')
req = Net::HTTP::Post.new(uri)
req['Authorization'] = 'Bearer sk_test_...'
req['Content-Type'] = 'application/json'
req.body = '{"fax_number":{"area_code":"415"}}'
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true){|http| http.request(req)}
puts res.body
```

#### PHP

```php
<?php
$ch = curl_init();
$data = json_encode(['fax_number' => ['area_code' => '415']]);
curl_setopt_array($ch, [
  CURLOPT_URL => 'https://api.medsender.com/api/v2/fax_numbers',
  CURLOPT_POST => true,
  CURLOPT_HTTPHEADER => ['Authorization: Bearer sk_test_...', 'Content-Type: application/json'],
  CURLOPT_POSTFIELDS => $data,
  CURLOPT_RETURNTRANSFER => true
]);
$res = curl_exec($ch);
echo $res;
```

#### Java

```java
import java.net.http.*;
import java.net.URI;
public class CreateNumber {
  public static void main(String[] args) throws Exception {
    var client = HttpClient.newHttpClient();
    var body = "{\"fax_number\":{\"area_code\":\"415\"}}";
    var req = HttpRequest.newBuilder()
      .uri(URI.create("https://api.medsender.com/api/v2/fax_numbers"))
      .header("Authorization", "Bearer sk_test_...")
      .header("Content-Type", "application/json")
      .POST(HttpRequest.BodyPublishers.ofString(body))
      .build();
    var res = client.send(req, HttpResponse.BodyHandlers.ofString());
    System.out.println(res.body());
  }
}
```

#### C#

```csharp
using System;
using System.Net.Http;
var url = "https://api.medsender.com/api/v2/fax_numbers";
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization","Bearer sk_test_...");
var json = "{\"fax_number\":{\"area_code\":\"415\"}}";
var res = await client.PostAsync(url, new StringContent(json, System.Text.Encoding.UTF8, "application/json"));
Console.WriteLine(await res.Content.ReadAsStringAsync());
```

Response

```json
{
  "fax_number": {
    "id": "a1b2c3d4-e5f6-4890-abcd-ef1234567890",
    "number": "+15550100099",
    "callback_url": null,
    "created_at": "2025-01-15T10:35:00.000Z",
    "client": null,
    "uri": "https://api.medsender.com/api/v2/fax_numbers/a1b2c3d4-e5f6-4890-abcd-ef1234567890"
  }
}
```

## Update Callback URL

PATCH `/fax_numbers/:id` — Updates the webhook callback URL for a fax number.

The `:id` parameter is the fax number's unique identifier (UUID).

#### cURL

```bash
curl -s -X PATCH -H "Authorization: Bearer sk_test_..." -H "Content-Type: application/json" -d '{"fax_number":{"callback_url":"https://example.com/webhooks/fax"}}' "https://api.medsender.com/api/v2/fax_numbers/YOUR_FAX_NUMBER_ID" | jq
```

#### Node

```javascript
const API_BASE='https://api.medsender.com/api/v2';
const API_KEY='sk_test_...';
const slug='REPLACE_SLUG';
const res=await fetch(`${API_BASE}/fax_numbers/${slug}`,{
  method:'PATCH',
  headers:{Authorization:`Bearer ${API_KEY}`,'Content-Type':'application/json'},
  body:JSON.stringify({fax_number:{callback_url:'https://example.com/webhooks/received_fax'}})
});
console.log(await res.json());
```

#### TypeScript

```typescript
const API_BASE: string='https://api.medsender.com/api/v2';
const API_KEY: string='sk_test_...';
const slug: string='REPLACE_SLUG';
const body = { fax_number: { callback_url: 'https://example.com/webhooks/received_fax' } };
const res = await fetch(`${API_BASE}/fax_numbers/${slug}`, { method:'PATCH', headers:{ Authorization: `Bearer ${API_KEY}`, 'Content-Type':'application/json' }, body: JSON.stringify(body) });
console.log(await res.json());
```

#### Python

```python
import requests, json
API_BASE='https://api.medsender.com/api/v2'
API_KEY='sk_test_...'
slug='REPLACE_SLUG'
body={'fax_number':{'callback_url':'https://example.com/webhooks/received_fax'}}
r=requests.patch(f"{API_BASE}/fax_numbers/{slug}", headers={'Authorization':f'Bearer {API_KEY}','Content-Type':'application/json'}, data=json.dumps(body))
print(r.json())
```

#### Ruby

```ruby
require 'net/http'
require 'uri'
slug = 'REPLACE_SLUG'
uri = URI.parse("https://api.medsender.com/api/v2/fax_numbers/#{slug}")
req = Net::HTTP::Patch.new(uri)
req['Authorization'] = 'Bearer sk_test_...'
req['Content-Type'] = 'application/json'
req.body = '{"fax_number":{"callback_url":"https://example.com/webhooks/received_fax"}}'
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true){|http| http.request(req)}
puts res.body
```

#### PHP

```php
<?php
$slug = 'REPLACE_SLUG';
$ch = curl_init();
$data = json_encode(['fax_number' => ['callback_url' => 'https://example.com/webhooks/received_fax']]);
curl_setopt_array($ch, [
  CURLOPT_URL => 'https://api.medsender.com/api/v2/fax_numbers/' . $slug,
  CURLOPT_CUSTOMREQUEST => 'PATCH',
  CURLOPT_HTTPHEADER => ['Authorization: Bearer sk_test_...', 'Content-Type: application/json'],
  CURLOPT_POSTFIELDS => $data,
  CURLOPT_RETURNTRANSFER => true
]);
$res = curl_exec($ch);
echo $res;
```

#### Java

```java
import java.net.http.*;
import java.net.URI;
public class UpdateNumber {
  public static void main(String[] args) throws Exception {
    var slug = "REPLACE_SLUG";
    var client = HttpClient.newHttpClient();
    var body = "{\"fax_number\":{\"callback_url\":\"https://example.com/webhooks/received_fax\"}}";
    var req = HttpRequest.newBuilder()
      .uri(URI.create("https://api.medsender.com/api/v2/fax_numbers/" + slug))
      .header("Authorization","Bearer sk_test_...")
      .header("Content-Type","application/json")
      .method("PATCH", HttpRequest.BodyPublishers.ofString(body))
      .build();
    var res = client.send(req, HttpResponse.BodyHandlers.ofString());
    System.out.println(res.body());
  }
}
```

#### C#

```csharp
using System;
using System.Net.Http;
var slug = "REPLACE_SLUG";
var url = "https://api.medsender.com/api/v2/fax_numbers/" + slug;
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization","Bearer sk_test_...");
var json = "{\"fax_number\":{\"callback_url\":\"https://example.com/webhooks/received_fax\"}}";
var method = new HttpMethod("PATCH");
var req = new HttpRequestMessage(method, url) { Content = new StringContent(json, System.Text.Encoding.UTF8, "application/json") };
var res = await client.SendAsync(req);
Console.WriteLine(await res.Content.ReadAsStringAsync());
```

Response

```json
{
  "fax_number": {
    "id": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
    "number": "+15550100001",
    "callback_url": "https://example.com/webhooks/fax",
    "created_at": "2025-01-15T10:30:00.000Z",
    "client": null,
    "uri": "https://api.medsender.com/api/v2/fax_numbers/f47ac10b-58cc-4372-a567-0e02b2c3d479"
  }
}
```
