> 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.

# Create alias address

POST https://%7BYour_Space_Name%7D.signalwire.com/api/fabric/alias_addresses
Content-Type: application/json

Creates an alias address that forwards to an existing resource in your project. `name` and `resource_id` are required; `display_name` defaults to `name`, `channels` to all three, `codecs` to none, and `context` to `public`. The handler resource can't be changed later: to point an alias at a different resource, delete it and create a new one.

#### Permissions

The API token used to authenticate must have the following scope(s) enabled to make a successful request: _Calling_, _Fax_, _Messaging_, or _Video_.

[Learn more about API scopes](/docs/platform/your-signalwire-api-space).

Reference: https://signalwire.com/docs/apis/rest/alias-addresses/create-alias-address

## Authentication

- `Authorization` header (basic auth, required) — SignalWire Basic Authentication using Project ID and API Token. The client sends HTTP requests with the Authorization header containing the word Basic followed by a space and a base64-encoded string of project_id:token. The project ID will be used as the username and the API token as the password. Example: ``` Authorization: Basic base64(project_id:token) ```

## Request

### Body (application/json)

This endpoint expects an object.

- `name` (string, required) — URL-safe name for the alias — lowercase letters and numbers, with underscores or dashes in place of spaces. Dashes can't start or end the name or appear twice in a row. Must be unique within its context and is used to build the alias's address.
- `resource_id` (string, required) — ID of the resource that handles calls and messages to this alias. Must reference a resource in your project. Cannot be changed after creation: to point an alias at a different resource, delete it and create a new one.
- `display_name` (string, optional) — Human-friendly label for the alias. Defaults to `name`.
- `channels` (list of enum, optional, default: ["audio","messaging","video"]) — Channels to enable on the alias. At least one is required. Defaults to all three.
  - Allowed values: `audio`, `messaging`, `video`
- `codecs` (list of enum, optional, default: []) — Codecs to enable for calls to the alias. Defaults to none.
  - Allowed values: `OPUS`, `G722`, `PCMU`, `PCMA`, `G729`, `VP8`, `H264`
- `context` (enum, optional, default: public) — Access context to create the alias in. Defaults to `public`.
  - Allowed values: `public`, `private`

## Response

### 201

The request has succeeded and a new resource has been created as a result.

- `id` (string, required) — Unique identifier for the alias address.
- `type` (enum, required) — The object type. Always `alias`.
  - Allowed values: `alias`
- `resource_id` (string, required) — ID of the resource that handles calls and messages to this alias.
- `name` (string, required) — URL-safe name for the alias. Used to build its address.
- `display_name` (string, required) — Human-friendly label for the alias. Defaults to `name`.
- `display_type` (enum, required) — Display type derived from the handler resource. Returned for reference only and cannot be set.
  - Allowed values: `app`, `room`, `call`, `subscriber`
- `channels` (list of enum, required) — Channels enabled on this alias.
  - Allowed values: `audio`, `messaging`, `video`
- `codecs` (list of enum, required) — Codecs enabled for calls to this alias. Empty when none are set.
  - Allowed values: `OPUS`, `G722`, `PCMU`, `PCMA`, `G729`, `VP8`, `H264`
- `context` (enum, required) — Access context the alias lives in.
  - Allowed values: `public`, `private`
- `uri` (string, required) — The resource address this alias resolves to, in the form `/<context>/<name>`.
- `created_at` (datetime, required) — Date and time when the alias address was created.
- `updated_at` (datetime, required) — Date and time when the alias address was last updated.

## Errors

### 400 Bad Request Error

The request is invalid.

- `error` (enum, required)
  - Allowed values: `Bad Request`

### 401 Unauthorized Error

Access is unauthorized.

- `error` (enum, required)
  - Allowed values: `Unauthorized`

### 422 Unprocessable Entity Error

The request contains invalid parameters. See errors for details.

- `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
{
  "name": "support",
  "resource_id": "b3877739-5c7e-4d4f-9d1a-2f0c8c2f1a11"
}
```

**Response**

```json
{
  "id": "8f14e45f-ceea-467d-9c2b-7a1d3a9b2c34",
  "type": "alias",
  "resource_id": "b3877739-5c7e-4d4f-9d1a-2f0c8c2f1a11",
  "name": "support",
  "display_name": "Support Line",
  "display_type": "app",
  "channels": [
    "audio",
    "messaging",
    "video"
  ],
  "codecs": [],
  "context": "public",
  "uri": "/public/support",
  "created_at": "2024-05-06T12:20:00Z",
  "updated_at": "2024-05-06T12:20:00Z"
}
```

**SDK Code**

```python
import requests

url = "https://{your_space_name}.signalwire.com/api/fabric/alias_addresses"

payload = {
    "name": "support",
    "resource_id": "b3877739-5c7e-4d4f-9d1a-2f0c8c2f1a11"
}
headers = {
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers, auth=("<project_id>", "<api_token>"))

print(response.json())
```

```javascript
const url = 'https://{your_space_name}.signalwire.com/api/fabric/alias_addresses';
const credentials = btoa("<project_id>:<api_token>");

const options = {
  method: 'POST',
  headers: {
    Authorization: `Basic ${credentials}`,
    'Content-Type': 'application/json'
  },
  body: '{"name":"support","resource_id":"b3877739-5c7e-4d4f-9d1a-2f0c8c2f1a11"}'
};

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/fabric/alias_addresses"

	payload := strings.NewReader("{\n  \"name\": \"support\",\n  \"resource_id\": \"b3877739-5c7e-4d4f-9d1a-2f0c8c2f1a11\"\n}")

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

	req.SetBasicAuth("<project_id>", "<api_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/fabric/alias_addresses")

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

request = Net::HTTP::Post.new(url)
request.basic_auth("<project_id>", "<api_token>")
request["Content-Type"] = 'application/json'
request.body = "{\n  \"name\": \"support\",\n  \"resource_id\": \"b3877739-5c7e-4d4f-9d1a-2f0c8c2f1a11\"\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.post("https://{your_space_name}.signalwire.com/api/fabric/alias_addresses")
  .basicAuth("<project_id>", "<api_token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"name\": \"support\",\n  \"resource_id\": \"b3877739-5c7e-4d4f-9d1a-2f0c8c2f1a11\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://{your_space_name}.signalwire.com/api/fabric/alias_addresses', [
  'body' => '{
  "name": "support",
  "resource_id": "b3877739-5c7e-4d4f-9d1a-2f0c8c2f1a11"
}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
    'auth' => ['<project_id>', '<api_token>'],
]);

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

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

var client = new RestClient("https://{your_space_name}.signalwire.com/api/fabric/alias_addresses");
client.Authenticator = new HttpBasicAuthenticator("<project_id>", "<api_token>");
var request = new RestRequest(Method.POST);

request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"name\": \"support\",\n  \"resource_id\": \"b3877739-5c7e-4d4f-9d1a-2f0c8c2f1a11\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let credentials = Data("<project_id>:<api_token>".utf8).base64EncodedString()

let headers = [
  "Authorization": "Basic \(credentials)",
  "Content-Type": "application/json"
]
let parameters = [
  "name": "support",
  "resource_id": "b3877739-5c7e-4d4f-9d1a-2f0c8c2f1a11"
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://{your_space_name}.signalwire.com/api/fabric/alias_addresses")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
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()
```