> 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 SIP credential POST https://%7BYour_Space_Name%7D.signalwire.com/api/fabric/resources/sip_endpoints Content-Type: application/json Creates a project-scoped SIP Credential for a SIP device to register with SignalWire. Use it for a shared or independently managed device; use [Create Subscriber SIP credential](/docs/apis/rest/subscribers/sip-credentials/create-subscriber-sip-credential) when the credential belongs to a specific Subscriber. To attach an already-existing resource as the credential's outbound call handler, use [Assign Resource to SIP credential](/docs/apis/rest/sip-credentials/assign-resource-to-sip-credential) instead. #### Permissions The API token used to authenticate must have the following scope(s) enabled to make a successful request: _Voice_, _Messaging_, _Fax_, or _Video_. [Learn more about API scopes](/docs/platform/your-signalwire-api-space). Reference: https://signalwire.com/docs/apis/rest/sip-credentials/create-sip-credential ## 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 a SipEndpointCreateRequest. - `id` (string, required) — The id of the Sip Endpoint - `username` (string, required) — The username of the Sip Endpoint - `caller_id` (string, required) — The caller ID that will showup when dialing from this Sip Endpoint - `send_as` (string, required) — The Sip username that will show up on the calle's side. Overrides the username. - `ciphers` (list of enum, required) — Ciphers that can be enabled for calls on this Sip Endpoint. - Allowed values: `AEAD_AES_256_GCM_8`, `AES_256_CM_HMAC_SHA1_80`, `AES_CM_128_HMAC_SHA1_80`, `AES_256_CM_HMAC_SHA1_32`, `AES_CM_128_HMAC_SHA1_32` - `codecs` (list of enum, required) — Codecs that can be enabled for calls on this Sip Endpoint. - Allowed values: `PCMU`, `PCMA`, `G722`, `G729`, `OPUS`, `OPUS@48000H@20I`, `OPUS@24000H@20I`, `OPUS@16000H@20I`, `OPUS@8000H@20I`, `VP8`, `H264` - `encryption` (enum, required) — The set encryption type on the Sip Endpoint. - Allowed values: `required`, `optional`, `default` - `call_handler` (enum, required) — Specify how the SIP endpoint will handle outbound calls. - **default**: The SIP endpoint will pull the outbound policy setting from the [SIP Profile Settings](https://my.signalwire.com?page=sip_profile/edit). This allows centralized management of outbound call behavior across multiple endpoints from a single configuration. - **passthrough**: The SIP endpoint will be allowed to dial PSTN numbers. This permits outbound calling to traditional phone numbers without restrictions. - **block-pstn**: The SIP endpoint will be blocked from dialing PSTN numbers. Use this to restrict the endpoint from initiating calls to the public telephone network. - **resource**: Outbound calls from this SIP endpoint will dial the specified resource and execute its instructions. Requires setting `calling_handler_resource_id` to a valid resource. This enables custom call handling workflows for outbound calls. - Allowed values: `default`, `passthrough`, `block-pstn`, `resource` - `calling_handler_resource_id` (string, required, nullable) — If `call_handler` is set to `resource`, this field expects the id of the set resouce. Will be `null` otherwise. ## Response ### 200 The request has succeeded. - `type` (string, required) — A string representation of the type of object this record is. - `id` (string, required) — The unique identifier of the SIP endpoint. - `username` (string, required) — The username for the SIP endpoint. - `caller_id` (string, required, nullable) — Friendly Caller ID used as the CNAM when dialing a phone number or the From when dialing another SIP Endpoint. - `send_as` (string, required) — When dialing a PSTN phone number, you must send it From a number you have purchased or verified. send_as indicates which number this endpoint has set as its origination. random indicates it will randomly choose a purchased or verified number from within the project. - `ciphers` (list of string, required) — A list of encryption ciphers this endpoint will support. - `codecs` (list of string, required) — A list of codecs this endpoint will support. - `encryption` (enum, required) — Whether connections to this endpoint require encryption or if encryption is optional. - Allowed values: `default`, `required`, `optional` - `call_handler` (enum, required, nullable) — What type of handler you want to run on inbound calls. - Allowed values: `relay_context`, `relay_topic`, `relay_application`, `relay_connector`, `relay_script`, `laml_webhooks`, `laml_application`, `dialogflow`, `video_room`, `call_flow`, `ai_agent` - `calling_handler_resource_id` (string, required, nullable) — The unique identifier of the calling handler resource. - `call_request_url` (string, required, nullable) — A string representing the LaML URL to access when a call is received. This is only used (and required) when call_handler is set to laml_webhooks. - `call_request_method` (enum, required, nullable) — A string representing the HTTP method to use with call_request_url. Valid values are GET and POST. - Allowed values: `GET`, `POST` - `call_fallback_url` (string, required, nullable) — A string representing the LaML URL to access when the call to call_request_url fails. This is only used (and required) when call_handler is set to laml_webhooks. - `call_fallback_method` (enum, required, nullable) — A string representing the HTTP method to use with call_fallback_url. Valid values are GET and POST. - Allowed values: `GET`, `POST` - `call_status_callback_url` (string, required, nullable) — A string representing a URL to send status change messages to. This is only used (and required) when call_handler is set to laml_webhooks. - `call_status_callback_method` (enum, required, nullable) — A string representing the HTTP method to use with call_status_callback_url. Valid values are GET and POST. - Allowed values: `GET`, `POST` - `call_laml_application_id` (string, required, nullable) — A string representing the ID of the LaML application to forward incoming calls to. This is only used (and required) when call_handler is set to laml_application. - `call_dialogflow_agent_id` (string, required, nullable) — A string representing the ID of the Dialogflow agent to forward incoming calls to. This is only used (and required) when call_handler is set to dialogflow. - `call_relay_topic` (string, required, nullable) — A string representing the Relay topic to forward incoming calls to. This is only used (and required) when call_handler is set to relay_topic. - `call_relay_topic_status_callback_url` (string, required, nullable) — A string representing a URL to send status change messages to. This is only used (and required) when call_handler is set to relay_topic. - `call_relay_context` (string, required, nullable) — A string representing the Relay context to forward incoming calls to. This is only used (and required) when call_handler is set to relay_context. - `call_relay_context_status_callback_url` (string, required, nullable) — A string representing a URL to send status change messages to. This is only used (and required) when call_handler is set to relay_context. - `call_relay_application` (string, required, nullable) — A string representing the Relay application to forward incoming calls to. This is only used (and required) when call_handler is set to relay_application. - `call_video_room_id` (string, required, nullable) — A string representing the ID of the Video Room to forward incoming calls to. This is only used (and required) when call_handler is set to video_room. - `call_relay_script_url` (string, required, nullable) — A string representing a URL of a SWML script to respond to incoming calls. This is only used (and required) when call_handler is set to relay_script. ## Errors ### 401 Unauthorized Error Access is unauthorized. - `error` (enum, required) - Allowed values: `Unauthorized` ### 404 Not Found Error The server cannot find the requested resource. - `error` (enum, required) - Allowed values: `Not Found` ### 422 Unprocessable Entity Error The request contains invalid parameters. See errors for details. - `errors` (list of Types.StatusCodes.RestApiErrorItem, required) — List of validation errors. ### 500 Internal Server Error An internal server error occurred. - `error` (enum, required) - Allowed values: `Internal Server Error` ## Types ### Types.StatusCodes.RestApiErrorItem Details about a specific error. - `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. ## Examples **Request** ```json { "id": "993ed018-9e79-4e50-b97b-984bd5534095", "username": "User", "caller_id": "123456789", "send_as": "Support", "ciphers": [ "AEAD_AES_256_GCM_8", "AES_256_CM_HMAC_SHA1_32" ], "codecs": [ "G722", "PCMA", "PCMU", "VP8" ], "encryption": "default", "call_handler": "default", "calling_handler_resource_id": "993ed018-9e79-4e50-b97b-984bd5534095" } ``` **Response** ```json { "type": "sip_endpoint", "id": "67075301-69b2-4fc3-8a2c-c95a69a5665e", "username": "c3p0", "caller_id": "C-3P0", "send_as": "random", "ciphers": [ "string" ], "codecs": [ "string" ], "encryption": "required", "call_handler": "ai_agent", "calling_handler_resource_id": "fe4093d9-58c2-4931-b4b9-5679f82652c6", "call_request_url": "string", "call_request_method": "POST", "call_fallback_url": "string", "call_fallback_method": "POST", "call_status_callback_url": "string", "call_status_callback_method": "POST", "call_laml_application_id": "string", "call_dialogflow_agent_id": "string", "call_relay_topic": "office", "call_relay_topic_status_callback_url": "https://myapplication/handle_relay_callbacks", "call_relay_context": "string", "call_relay_context_status_callback_url": "https://myapplication/handle_relay_callbacks", "call_relay_application": "string", "call_video_room_id": "string", "call_relay_script_url": "https://dev.signalwire.com/relay-bins/f9d13f68-f71e-4042-95bb-b07b9e2f2f92" } ``` **SDK Code** ```python import requests url = "https://{your_space_name}.signalwire.com/api/fabric/resources/sip_endpoints" payload = { "id": "993ed018-9e79-4e50-b97b-984bd5534095", "username": "User", "caller_id": "123456789", "send_as": "Support", "ciphers": ["AEAD_AES_256_GCM_8", "AES_256_CM_HMAC_SHA1_32"], "codecs": ["G722", "PCMA", "PCMU", "VP8"], "encryption": "default", "call_handler": "default", "calling_handler_resource_id": "993ed018-9e79-4e50-b97b-984bd5534095" } headers = { "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers, auth=("", "")) print(response.json()) ``` ```javascript const url = 'https://{your_space_name}.signalwire.com/api/fabric/resources/sip_endpoints'; const credentials = btoa(":"); const options = { method: 'POST', headers: { Authorization: `Basic ${credentials}`, 'Content-Type': 'application/json' }, body: '{"id":"993ed018-9e79-4e50-b97b-984bd5534095","username":"User","caller_id":"123456789","send_as":"Support","ciphers":["AEAD_AES_256_GCM_8","AES_256_CM_HMAC_SHA1_32"],"codecs":["G722","PCMA","PCMU","VP8"],"encryption":"default","call_handler":"default","calling_handler_resource_id":"993ed018-9e79-4e50-b97b-984bd5534095"}' }; 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/resources/sip_endpoints" payload := strings.NewReader("{\n \"id\": \"993ed018-9e79-4e50-b97b-984bd5534095\",\n \"username\": \"User\",\n \"caller_id\": \"123456789\",\n \"send_as\": \"Support\",\n \"ciphers\": [\n \"AEAD_AES_256_GCM_8\",\n \"AES_256_CM_HMAC_SHA1_32\"\n ],\n \"codecs\": [\n \"G722\",\n \"PCMA\",\n \"PCMU\",\n \"VP8\"\n ],\n \"encryption\": \"default\",\n \"call_handler\": \"default\",\n \"calling_handler_resource_id\": \"993ed018-9e79-4e50-b97b-984bd5534095\"\n}") req, _ := http.NewRequest("POST", url, payload) req.SetBasicAuth("", "") 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/resources/sip_endpoints") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request.basic_auth("", "") request["Content-Type"] = 'application/json' request.body = "{\n \"id\": \"993ed018-9e79-4e50-b97b-984bd5534095\",\n \"username\": \"User\",\n \"caller_id\": \"123456789\",\n \"send_as\": \"Support\",\n \"ciphers\": [\n \"AEAD_AES_256_GCM_8\",\n \"AES_256_CM_HMAC_SHA1_32\"\n ],\n \"codecs\": [\n \"G722\",\n \"PCMA\",\n \"PCMU\",\n \"VP8\"\n ],\n \"encryption\": \"default\",\n \"call_handler\": \"default\",\n \"calling_handler_resource_id\": \"993ed018-9e79-4e50-b97b-984bd5534095\"\n}" response = http.request(request) puts response.read_body ``` ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://{your_space_name}.signalwire.com/api/fabric/resources/sip_endpoints") .basicAuth("", "") .header("Content-Type", "application/json") .body("{\n \"id\": \"993ed018-9e79-4e50-b97b-984bd5534095\",\n \"username\": \"User\",\n \"caller_id\": \"123456789\",\n \"send_as\": \"Support\",\n \"ciphers\": [\n \"AEAD_AES_256_GCM_8\",\n \"AES_256_CM_HMAC_SHA1_32\"\n ],\n \"codecs\": [\n \"G722\",\n \"PCMA\",\n \"PCMU\",\n \"VP8\"\n ],\n \"encryption\": \"default\",\n \"call_handler\": \"default\",\n \"calling_handler_resource_id\": \"993ed018-9e79-4e50-b97b-984bd5534095\"\n}") .asString(); ``` ```php request('POST', 'https://{your_space_name}.signalwire.com/api/fabric/resources/sip_endpoints', [ 'body' => '{ "id": "993ed018-9e79-4e50-b97b-984bd5534095", "username": "User", "caller_id": "123456789", "send_as": "Support", "ciphers": [ "AEAD_AES_256_GCM_8", "AES_256_CM_HMAC_SHA1_32" ], "codecs": [ "G722", "PCMA", "PCMU", "VP8" ], "encryption": "default", "call_handler": "default", "calling_handler_resource_id": "993ed018-9e79-4e50-b97b-984bd5534095" }', 'headers' => [ 'Content-Type' => 'application/json', ], 'auth' => ['', ''], ]); echo $response->getBody(); ``` ```csharp using RestSharp; using RestSharp.Authenticators; var client = new RestClient("https://{your_space_name}.signalwire.com/api/fabric/resources/sip_endpoints"); client.Authenticator = new HttpBasicAuthenticator("", ""); var request = new RestRequest(Method.POST); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"id\": \"993ed018-9e79-4e50-b97b-984bd5534095\",\n \"username\": \"User\",\n \"caller_id\": \"123456789\",\n \"send_as\": \"Support\",\n \"ciphers\": [\n \"AEAD_AES_256_GCM_8\",\n \"AES_256_CM_HMAC_SHA1_32\"\n ],\n \"codecs\": [\n \"G722\",\n \"PCMA\",\n \"PCMU\",\n \"VP8\"\n ],\n \"encryption\": \"default\",\n \"call_handler\": \"default\",\n \"calling_handler_resource_id\": \"993ed018-9e79-4e50-b97b-984bd5534095\"\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let credentials = Data(":".utf8).base64EncodedString() let headers = [ "Authorization": "Basic \(credentials)", "Content-Type": "application/json" ] let parameters = [ "id": "993ed018-9e79-4e50-b97b-984bd5534095", "username": "User", "caller_id": "123456789", "send_as": "Support", "ciphers": ["AEAD_AES_256_GCM_8", "AES_256_CM_HMAC_SHA1_32"], "codecs": ["G722", "PCMA", "PCMU", "VP8"], "encryption": "default", "call_handler": "default", "calling_handler_resource_id": "993ed018-9e79-4e50-b97b-984bd5534095" ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://{your_space_name}.signalwire.com/api/fabric/resources/sip_endpoints")! 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() ```