> Fetch clean Markdown by appending `.md` to any page URL under https://signalwire.com/docs or requesting it with the HTTP header `Accept: text/markdown`. The root index at https://signalwire.com/docs/llms.txt lists the available documentation indexes.

# Update the billing profile

PUT https://%7BYour_Space_Name%7D.signalwire.com/api/space/billing_profile
Content-Type: application/json

Replaces the billing profile. The update writes the whole profile, so send every field
you want to keep. `contact_email` takes an array of one or more addresses.

`tax_id_number` is required when the profile reports `tax_id_number_required: true`,
which is the case on Enterprise spaces. On a postpay space, `monthly_invoices` is locked
on and `false` is rejected with `monthly_invoices_locked`; the profile reports this as
`monthly_invoices_locked: true` so a client does not have to infer it.

#### Permissions

Authenticate with a [Personal access token](/docs/apis/authorization#personal-access-tokens) whose holder is an owner or admin of the space. A project API token is not accepted on this endpoint, and a Personal access token has no scopes: the holder's role in the space is the whole authorization decision.

Reference: https://signalwire.com/docs/apis/rest/space/billing/update-billing-profile

## Authentication

- `Authorization` header (basic auth, required) — Personal access token authentication for space-wide administration. Send HTTP Basic auth with an empty username and the Personal access token as the password. A Personal access token carries your own authority rather than a project's: it is created from your user menu in the Dashboard, is prefixed `pat_`, and has no scopes. The holder must be an owner or admin of the space named by the subdomain, and the token acts only on that space. Example: ``` Authorization: Basic base64(:pat_...) ```

## Request

### Body (application/json)

This endpoint expects an object.

- `address_line1` (string, required) — The first line of the billing address.
- `address_city` (string, required) — The city of the billing address.
- `address_state` (string, required) — The state, province, or region of the billing address.
- `address_zip` (string, required) — The postal code of the billing address.
- `address_country` (string, required) — The ISO 3166-1 alpha-2 country code of the billing address.
- `company_name` (string, required) — The company name to show on statements.
- `contact_name` (string, required) — The name of the billing contact.
- `contact_email` (list of string, required) — The email addresses to send billing correspondence to. Must be an array (`contact_email_must_be_array`) with at least one address (`contact_email_missing`), each a valid email address (`contact_email_address_invalid`).
- `contact_phone` (string, required) — The phone number of the billing contact.
- `address_line2` (string, optional) — The second line of the billing address.
- `tax_id_number` (string, optional) — The tax identification number to show on statements. Required when the profile reports `tax_id_number_required: true`, which is the case on Enterprise spaces.
- `monthly_invoices` (boolean, optional, default: false) — Whether to issue a monthly invoice. On a postpay space this is locked on, and `false` is rejected with `monthly_invoices_locked`.

## Response

### 200

The request has succeeded.

- `type` (enum, required) — The object type. Always `billing_profile`.
  - Allowed values: `billing_profile`
- `address_line1` (string, required, nullable) — The first line of the billing address.
- `address_line2` (string, required, nullable) — The second line of the billing address.
- `address_city` (string, required, nullable) — The city of the billing address.
- `address_state` (string, required, nullable) — The state, province, or region of the billing address.
- `address_zip` (string, required, nullable) — The postal code of the billing address.
- `address_country` (string, required, nullable) — The ISO 3166-1 alpha-2 country code of the billing address.
- `company_name` (string, required, nullable) — The company name that appears on statements.
- `contact_name` (string, required, nullable) — The name of the billing contact.
- `contact_email` (list of string, required, nullable) — The email addresses billing correspondence is sent to.
- `contact_phone` (string, required, nullable) — The phone number of the billing contact.
- `tax_id_number` (string, required, nullable) — The tax identification number that appears on statements.
- `monthly_invoices` (boolean, required) — Whether a monthly invoice is issued for the space.
- `tax_id_number_required` (boolean, required) — Whether `tax_id_number` is required when updating the profile. `true` on Enterprise spaces.
- `monthly_invoices_locked` (boolean, required) — Whether `monthly_invoices` is locked on. `true` on postpay spaces, where monthly invoices cannot be turned off.

## Errors

### 400 Bad Request Error

The request body is not valid JSON.

- `errors` (list of object, required) — List of validation errors.
  - `type` (string, required) — The category of error.
  - `code` (string, required) — A specific error code.
  - `message` (string, required) — A description of what caused the error.
  - `url` (string, required) — A link to documentation about this error.
  - `attribute` (string, optional, nullable) — The request parameter that caused the error, if applicable.

### 401 Unauthorized Error

The credential is missing, unknown, or revoked; its holder is not a member of the space in the subdomain; the member is not an owner or admin; or billing for this space is not managed in the space itself, which is the case for a space purchased through a cloud marketplace and for a suspended or deactivated space. A space deactivated for nonpayment keeps the billing endpoints so that its outstanding balance can be settled. The body is the plain text `Unauthorized`. An unverified space instead receives the JSON body `{"message": "Please validate a phone number to access your account."}` on every endpoint under `/api/space`.

- `message` (string, required) — States that a phone number must be validated for the space before it can use the API.

### 422 Unprocessable Entity Error

The request failed validation. `contact_email` was not an array (`contact_email_must_be_array`), was empty (`contact_email_missing`), or held an address that is not a valid email address (`contact_email_address_invalid`); a required field was blank; `tax_id_number` was omitted on a space that requires it; or a postpay space tried to set `monthly_invoices` to `false` (`monthly_invoices_locked`).

- `errors` (list of object, required) — List of validation errors.
  - `type` (string, required) — The category of error.
  - `code` (string, required) — A specific error code.
  - `message` (string, required) — A description of what caused the error.
  - `url` (string, required) — A link to documentation about this error.
  - `attribute` (string, optional, nullable) — The request parameter that caused the error, if applicable.

### 500 Internal Server Error

An internal server error occurred.

- `error` (enum, required)
  - Allowed values: `Internal Server Error`

## Examples

**Request**

```json
{
  "address_line1": "1234 Main St",
  "address_city": "Austin",
  "address_state": "TX",
  "address_zip": "78701",
  "address_country": "US",
  "company_name": "Acme Inc",
  "contact_name": "Jane Doe",
  "contact_email": [
    "jane@example.com",
    "billing@example.com"
  ],
  "contact_phone": "+15125550100"
}
```

**Response**

```json
{
  "type": "billing_profile",
  "address_line1": "1234 Main St",
  "address_line2": "Suite 200",
  "address_city": "Austin",
  "address_state": "TX",
  "address_zip": "78701",
  "address_country": "US",
  "company_name": "Acme Inc",
  "contact_name": "Jane Doe",
  "contact_email": [
    "jane@example.com",
    "billing@example.com"
  ],
  "contact_phone": "+15125550100",
  "tax_id_number": "12-3456789",
  "monthly_invoices": false,
  "tax_id_number_required": false,
  "monthly_invoices_locked": false
}
```

**SDK Code**

```python
import requests

url = "https://{your_space_name}.signalwire.com/api/space/billing_profile"

payload = {
    "address_line1": "1234 Main St",
    "address_city": "Austin",
    "address_state": "TX",
    "address_zip": "78701",
    "address_country": "US",
    "company_name": "Acme Inc",
    "contact_name": "Jane Doe",
    "contact_email": ["jane@example.com", "billing@example.com"],
    "contact_phone": "+15125550100"
}
headers = {
    "Content-Type": "application/json"
}

response = requests.put(url, json=payload, headers=headers, auth=("<username>", "<personal_access_token>"))

print(response.json())
```

```javascript
const url = 'https://{your_space_name}.signalwire.com/api/space/billing_profile';
const credentials = btoa("<username>:<personal_access_token>");

const options = {
  method: 'PUT',
  headers: {
    Authorization: `Basic ${credentials}`,
    'Content-Type': 'application/json'
  },
  body: '{"address_line1":"1234 Main St","address_city":"Austin","address_state":"TX","address_zip":"78701","address_country":"US","company_name":"Acme Inc","contact_name":"Jane Doe","contact_email":["jane@example.com","billing@example.com"],"contact_phone":"+15125550100"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://{your_space_name}.signalwire.com/api/space/billing_profile"

	payload := strings.NewReader("{\n  \"address_line1\": \"1234 Main St\",\n  \"address_city\": \"Austin\",\n  \"address_state\": \"TX\",\n  \"address_zip\": \"78701\",\n  \"address_country\": \"US\",\n  \"company_name\": \"Acme Inc\",\n  \"contact_name\": \"Jane Doe\",\n  \"contact_email\": [\n    \"jane@example.com\",\n    \"billing@example.com\"\n  ],\n  \"contact_phone\": \"+15125550100\"\n}")

	req, _ := http.NewRequest("PUT", url, payload)

	req.SetBasicAuth("<username>", "<personal_access_token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://{your_space_name}.signalwire.com/api/space/billing_profile")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Put.new(url)
request.basic_auth("<username>", "<personal_access_token>")
request["Content-Type"] = 'application/json'
request.body = "{\n  \"address_line1\": \"1234 Main St\",\n  \"address_city\": \"Austin\",\n  \"address_state\": \"TX\",\n  \"address_zip\": \"78701\",\n  \"address_country\": \"US\",\n  \"company_name\": \"Acme Inc\",\n  \"contact_name\": \"Jane Doe\",\n  \"contact_email\": [\n    \"jane@example.com\",\n    \"billing@example.com\"\n  ],\n  \"contact_phone\": \"+15125550100\"\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.put("https://{your_space_name}.signalwire.com/api/space/billing_profile")
  .basicAuth("<username>", "<personal_access_token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"address_line1\": \"1234 Main St\",\n  \"address_city\": \"Austin\",\n  \"address_state\": \"TX\",\n  \"address_zip\": \"78701\",\n  \"address_country\": \"US\",\n  \"company_name\": \"Acme Inc\",\n  \"contact_name\": \"Jane Doe\",\n  \"contact_email\": [\n    \"jane@example.com\",\n    \"billing@example.com\"\n  ],\n  \"contact_phone\": \"+15125550100\"\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('PUT', 'https://{your_space_name}.signalwire.com/api/space/billing_profile', [
  'body' => '{
  "address_line1": "1234 Main St",
  "address_city": "Austin",
  "address_state": "TX",
  "address_zip": "78701",
  "address_country": "US",
  "company_name": "Acme Inc",
  "contact_name": "Jane Doe",
  "contact_email": [
    "jane@example.com",
    "billing@example.com"
  ],
  "contact_phone": "+15125550100"
}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
    'auth' => ['<username>', '<personal_access_token>'],
]);

echo $response->getBody();
```

```csharp
using RestSharp;
using RestSharp.Authenticators;

var client = new RestClient("https://{your_space_name}.signalwire.com/api/space/billing_profile");
client.Authenticator = new HttpBasicAuthenticator("<username>", "<personal_access_token>");
var request = new RestRequest(Method.PUT);

request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"address_line1\": \"1234 Main St\",\n  \"address_city\": \"Austin\",\n  \"address_state\": \"TX\",\n  \"address_zip\": \"78701\",\n  \"address_country\": \"US\",\n  \"company_name\": \"Acme Inc\",\n  \"contact_name\": \"Jane Doe\",\n  \"contact_email\": [\n    \"jane@example.com\",\n    \"billing@example.com\"\n  ],\n  \"contact_phone\": \"+15125550100\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let credentials = Data("<username>:<personal_access_token>".utf8).base64EncodedString()

let headers = [
  "Authorization": "Basic \(credentials)",
  "Content-Type": "application/json"
]
let parameters = [
  "address_line1": "1234 Main St",
  "address_city": "Austin",
  "address_state": "TX",
  "address_zip": "78701",
  "address_country": "US",
  "company_name": "Acme Inc",
  "contact_name": "Jane Doe",
  "contact_email": ["jane@example.com", "billing@example.com"],
  "contact_phone": "+15125550100"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://{your_space_name}.signalwire.com/api/space/billing_profile")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PUT"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```