Skip to navigation

Create SWML Script

View as MarkdownOpen in Claude

Creates a resource that stores a calling or messaging SWML document in SignalWire. Use it for versioned instructions that can run without fetching content from your server; choose Create SWML webhook when your server must generate different SWML for each request, or Create cXML Script for cXML applications.

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.

Authentication

AuthorizationBasic

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

This endpoint expects an object.
namestringRequired
Name of the SWML Script.
contentsmap from strings to any or stringRequired

The SWML document, as a JSON object or as a string of JSON or YAML. A Calling Script uses calling SWML methods; a Messaging Script uses messaging SWML methods.

script_typeenumOptionalDefaults to calling

The kind of script to create. Defaults to calling when omitted, so set it to messaging explicitly to create a Messaging Script.

Allowed values:
status_callback_urlstringOptionalformat: "uri"
URL that receives status callbacks for messages sent or calls made by this script.

Response

The request has succeeded and a new resource has been created as a result.
idstringformat: "uuid"
Unique ID of the SWML Script.
project_idstringformat: "uuid"
Unique ID of the Project.
display_namestring
Display name of the SWML Script Fabric Resource
typeenum
Type of the Fabric Resource
Allowed values:
created_atdatetime
Date and time when the resource was created.
updated_atdatetime
Date and time when the resource was updated.
swml_scriptobject
SWML Script data.

Errors

422
Unprocessable Entity Error
500
Internal Server Error