create

View as MarkdownOpen in Claude

Create a new SWML script resource.

Request

Create Calling ScriptobjectRequired
Request body to create a SWML Script that handles inbound or outbound calls.
OR
Create Messaging ScriptobjectRequired
Request body to create a SWML Script that handles inbound SMS or MMS messages.

Response

idstringRequiredformat: "uuid"
Unique ID of the SWML Script.
project_idstringRequiredformat: "uuid"
Unique ID of the Project.
display_namestringRequired
Display name of the SWML Script Fabric Resource
typeenumRequired
Type of the Fabric Resource
created_atdatetimeRequired
Date and time when the resource was created.
updated_atdatetimeRequired
Date and time when the resource was updated.
swml_scriptobjectRequired
SWML Script data.

Response Example

Response
1{
2 "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
3 "project_id": "1313fe58-5e14-4c11-bbe7-6fdfa11fe780",
4 "display_name": "Reply Bot",
5 "type": "swml_script",
6 "created_at": "2024-05-06T12:20:00Z",
7 "updated_at": "2024-05-06T12:25:00Z",
8 "swml_script": {
9 "contents": {
10 "sections": {
11 "main": [
12 {
13 "reply": "Thanks for your message!"
14 }
15 ]
16 },
17 "version": "1.0.0"
18 },
19 "display_name": "Reply Bot",
20 "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
21 "request_url": "https://example.com/swml_script",
22 "script_type": "messaging"
23 }
24}

Example

1import { RestClient } from "@signalwire/sdk";
2
3const client = new RestClient({
4 project: "your-project-id",
5 token: "your-api-token",
6 host: "your-space.signalwire.com",
7});
8
9const result = await client.fabric.swmlScripts.create({
10 name: "my-item",
11});
12console.log(`Created: ${result.id}`);