> This page is for Server SDKs.

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

# get

> Retrieve a single SWML script resource.

Retrieve a single SWML script resource.

### Schema

```yaml
openapi: 3.1.0
info:
  title: API
  version: 1.0.0
paths:
  /api/fabric/resources/swml_scripts/{id}:
    get:
      operationId: subpackageSwmlScripts_get_swml_script
      summary: Get SWML Script
      description: >-
        Retrieves one stored SWML Script by resource ID so you can inspect the
        instructions used by its calling or messaging handler. Use [List SWML
        Scripts](/docs/apis/rest/swml-scripts/list-swml-scripts) to discover
        IDs, or a [SWML
        Webhook](/docs/apis/rest/swml-webhook/create-swml-webhook) when
        instructions must come from your server at request time.


        #### 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).
      tags:
        - subpackage_swmlScripts
      parameters:
        - name: id
          in: path
          description: Unique ID of a SWML Script.
          required: true
          schema:
            $ref: '#/components/schemas/uuid'
      responses:
        '200':
          description: The request has succeeded.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SwmlScriptResponse'
        '401':
          description: Access is unauthorized.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Types.StatusCodes.StatusCode401'
        '404':
          description: The server cannot find the requested resource.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Types.StatusCodes.StatusCode404'
        '500':
          description: An internal server error occurred.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Types.StatusCodes.StatusCode500'
tags:
  - name: subpackage_swmlScripts
servers:
  - url: https://%7BYour_Space_Name%7D.signalwire.com
    description: SignalWire API
components:
  schemas:
    uuid:
      type: string
      format: uuid
      description: Universal Unique Identifier.
      title: uuid
    SwmlScriptResponseType:
      type: string
      enum:
        - swml_script
      description: Type of the Fabric Resource
      title: SwmlScriptResponseType
    CallingSwmlScriptScriptType:
      type: string
      enum:
        - calling
      description: Set to `calling` for SWML Scripts that handle inbound or outbound calls.
      title: CallingSwmlScriptScriptType
    CallingSwmlScriptContents:
      type: object
      properties: {}
      description: >-
        The calling SWML document executed when this script runs. Uses [calling
        SWML methods](/docs/swml/reference/calling).
      title: CallingSwmlScriptContents
    CallingSwmlScriptStatusCallbackMethod:
      type: string
      enum:
        - POST
      description: HTTP method used for status callbacks.
      title: CallingSwmlScriptStatusCallbackMethod
    CallingSwmlScript:
      type: object
      properties:
        id:
          $ref: '#/components/schemas/uuid'
          description: Unique ID of a SWML Script.
        display_name:
          type: string
          description: The displayed name of the SWML script.
        script_type:
          $ref: '#/components/schemas/CallingSwmlScriptScriptType'
          description: >-
            Set to `calling` for SWML Scripts that handle inbound or outbound
            calls.
        request_url:
          type: string
          format: uri
          description: URL where this SWML Script is hosted.
        contents:
          $ref: '#/components/schemas/CallingSwmlScriptContents'
          description: >-
            The calling SWML document executed when this script runs. Uses
            [calling SWML methods](/docs/swml/reference/calling).
        status_callback_url:
          type: string
          format: uri
          description: >-
            URL that receives status callbacks for messages sent or calls made
            by this script.
        status_callback_method:
          $ref: '#/components/schemas/CallingSwmlScriptStatusCallbackMethod'
          description: HTTP method used for status callbacks.
      required:
        - id
        - display_name
        - script_type
        - request_url
        - contents
      description: >-
        A SWML Script that handles inbound or outbound calls. The `contents`
        field carries a [calling SWML document](/docs/swml/reference/calling).
      title: CallingSwmlScript
    MessagingSwmlScriptScriptType:
      type: string
      enum:
        - messaging
      description: >-
        Set to `messaging` for SWML Scripts that handle inbound SMS or MMS
        messages.
      title: MessagingSwmlScriptScriptType
    MessagingSwmlScriptContents:
      type: object
      properties: {}
      description: >-
        The messaging SWML document executed when this script runs. Uses
        [messaging SWML methods](/docs/swml/reference/messaging).
      title: MessagingSwmlScriptContents
    MessagingSwmlScript:
      type: object
      properties:
        id:
          $ref: '#/components/schemas/uuid'
          description: Unique ID of a SWML Script.
        display_name:
          type: string
          description: The displayed name of the SWML script.
        script_type:
          $ref: '#/components/schemas/MessagingSwmlScriptScriptType'
          description: >-
            Set to `messaging` for SWML Scripts that handle inbound SMS or MMS
            messages.
        request_url:
          type: string
          format: uri
          description: URL where this SWML Script is hosted.
        contents:
          $ref: '#/components/schemas/MessagingSwmlScriptContents'
          description: >-
            The messaging SWML document executed when this script runs. Uses
            [messaging SWML methods](/docs/swml/reference/messaging).
      required:
        - id
        - display_name
        - script_type
        - request_url
        - contents
      description: >-
        A SWML Script that handles inbound SMS or MMS messages. The `contents`
        field carries a [messaging SWML
        document](/docs/swml/reference/messaging).
      title: MessagingSwmlScript
    SwmlScript:
      oneOf:
        - $ref: '#/components/schemas/CallingSwmlScript'
        - $ref: '#/components/schemas/MessagingSwmlScript'
      description: >-
        A SWML Script — either a [Calling Script](#schema/CallingSwmlScript) for
        inbound or

        outbound calls, or a [Messaging Script](#schema/MessagingSwmlScript) for
        inbound SMS or

        MMS messages. The `script_type` field on each script (`"calling"` or
        `"messaging"`)

        identifies which kind it is.
      title: SwmlScript
    SwmlScriptResponse:
      type: object
      properties:
        id:
          $ref: '#/components/schemas/uuid'
          description: Unique ID of the SWML Script.
        project_id:
          $ref: '#/components/schemas/uuid'
          description: Unique ID of the Project.
        display_name:
          type: string
          description: Display name of the SWML Script Fabric Resource
        type:
          $ref: '#/components/schemas/SwmlScriptResponseType'
          description: Type of the Fabric Resource
        created_at:
          type: string
          format: date-time
          description: Date and time when the resource was created.
        updated_at:
          type: string
          format: date-time
          description: Date and time when the resource was updated.
        swml_script:
          $ref: '#/components/schemas/SwmlScript'
          description: SWML Script data.
      required:
        - id
        - project_id
        - display_name
        - type
        - created_at
        - updated_at
        - swml_script
      title: SwmlScriptResponse
    TypesStatusCodesStatusCode401Error:
      type: string
      enum:
        - Unauthorized
      title: TypesStatusCodesStatusCode401Error
    Types.StatusCodes.StatusCode401:
      type: object
      properties:
        error:
          $ref: '#/components/schemas/TypesStatusCodesStatusCode401Error'
      required:
        - error
      description: Access is unauthorized.
      title: Types.StatusCodes.StatusCode401
    TypesStatusCodesStatusCode404Error:
      type: string
      enum:
        - Not Found
      title: TypesStatusCodesStatusCode404Error
    Types.StatusCodes.StatusCode404:
      type: object
      properties:
        error:
          $ref: '#/components/schemas/TypesStatusCodesStatusCode404Error'
      required:
        - error
      description: The server cannot find the requested resource.
      title: Types.StatusCodes.StatusCode404
    TypesStatusCodesStatusCode500Error:
      type: string
      enum:
        - Internal Server Error
      title: TypesStatusCodesStatusCode500Error
    Types.StatusCodes.StatusCode500:
      type: object
      properties:
        error:
          $ref: '#/components/schemas/TypesStatusCodesStatusCode500Error'
      required:
        - error
      description: An internal server error occurred.
      title: Types.StatusCodes.StatusCode500

```

## **Response Example**

### Response (200)

```json
{
  "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
  "project_id": "1313fe58-5e14-4c11-bbe7-6fdfa11fe780",
  "display_name": "Reply Bot",
  "type": "swml_script",
  "created_at": "2024-05-06T12:20:00Z",
  "updated_at": "2024-05-06T12:25:00Z",
  "swml_script": {
    "contents": {
      "sections": {
        "main": [
          {
            "reply": "Thanks for your message!"
          }
        ]
      },
      "version": "1.0.0"
    },
    "display_name": "Reply Bot",
    "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
    "request_url": "https://example.com/swml_script",
    "script_type": "messaging"
  }
}
```

## **Example**

```python {9}
from signalwire.rest import RestClient

client = RestClient(
    project="your-project-id",
    token="your-api-token",
    host="your-space.signalwire.com",
)

item = client.fabric.swml_scripts.get("resource-id")
print(f"Swml Script: {item['display_name']}, ID: {item['id']}")
```