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

# update

> Replace a cXML script resource.

Replace a cXML script resource. Uses PUT for full replacement.

### Schema

```yaml
openapi: 3.1.0
info:
  title: API
  version: 1.0.0
paths:
  /api/fabric/resources/cxml_scripts/{id}:
    put:
      operationId: subpackageCXmlScripts_update_cxml_script
      summary: Update cXML Script
      description: >-
        Changes a stored cXML Script while preserving its Fabric resource and
        addresses. The change is also visible through Compatibility [Update a
        cXML
        Script](/docs/compatibility-api/rest/cxml-scripts/update-cxml-script),
        which manages the same script by LamlBin SID. Use [Update cXML
        webhook](/docs/apis/rest/cxml-webhook/update-cxml-webhook) for a
        server-backed handler.


        #### 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_cXmlScripts
      parameters:
        - name: id
          in: path
          description: Unique ID of a cXML Script.
          required: true
          schema:
            $ref: '#/components/schemas/uuid'
      responses:
        '200':
          description: The request has succeeded.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CXMLScriptResponse'
        '422':
          description: The request contains invalid parameters. See errors for details.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CXMLScriptUpdateStatusCode422'
        '500':
          description: An internal server error occurred.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Types.StatusCodes.StatusCode500'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CXMLScriptUpdateRequest'
tags:
  - name: subpackage_cXmlScripts
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
    RequestUrlMethodType:
      type: string
      enum:
        - GET
        - POST
      description: The method type to use for the URL
      title: RequestUrlMethodType
    CXMLScriptUpdateRequest:
      type: object
      properties:
        name:
          type: string
          description: Name of the cXML Script. Omit to keep the current name.
        contents:
          type: string
          description: The cXML script contents
        status_callback_url:
          type: string
          format: uri
          description: URL to send status callbacks to
        status_callback_method:
          $ref: '#/components/schemas/RequestUrlMethodType'
          description: HTTP method to use for status callbacks
      title: CXMLScriptUpdateRequest
    CxmlScriptResponseType:
      type: string
      enum:
        - cxml_script
      description: Type of the Fabric Resource
      title: CxmlScriptResponseType
    CxmlScriptScriptType:
      type: string
      enum:
        - calling
        - messaging
      description: The script type the cXML Script is used for
      title: CxmlScriptScriptType
    CXMLScript:
      type: object
      properties:
        id:
          $ref: '#/components/schemas/uuid'
          description: Unique ID of a cXML Script.
        contents:
          type: string
          description: The cXML script contents
        request_count:
          type: integer
          description: The amout of times the cXML script has been requested
        last_accessed_at:
          type:
            - string
            - 'null'
          format: date-time
          description: The date and time when the cXML script was last accessed
        request_url:
          type: string
          format: uri
          description: The URL where the cXML script can be accessed
        script_type:
          $ref: '#/components/schemas/CxmlScriptScriptType'
          description: The script type the cXML Script is used for
        display_name:
          type: string
          description: Display name of the cXML Script Fabric Resource
        status_callback_url:
          type:
            - string
            - 'null'
          format: uri
          description: The url that will send status updates for the cXML Script
        status_callback_method:
          $ref: '#/components/schemas/RequestUrlMethodType'
          description: HTTP method for status callback URL
      required:
        - id
        - contents
        - request_count
        - last_accessed_at
        - request_url
        - script_type
        - display_name
      title: CXMLScript
    CXMLScriptResponse:
      type: object
      properties:
        id:
          $ref: '#/components/schemas/uuid'
          description: Unique ID of the cXML Script.
        project_id:
          $ref: '#/components/schemas/uuid'
          description: Unique ID of the Project.
        name:
          type: string
          description: Display name of the cXML Script Fabric Resource
        type:
          $ref: '#/components/schemas/CxmlScriptResponseType'
          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.
        cxml_script:
          $ref: '#/components/schemas/CXMLScript'
          description: cXML Script data.
      required:
        - id
        - project_id
        - name
        - type
        - created_at
        - updated_at
        - cxml_script
      title: CXMLScriptResponse
    Types.StatusCodes.RestApiErrorItem:
      type: object
      properties:
        type:
          type: string
          description: The category of error.
        code:
          type: string
          description: A specific error code.
        message:
          type: string
          description: A description of what caused the error.
        attribute:
          type:
            - string
            - 'null'
          description: The request parameter that caused the error, if applicable.
        url:
          type: string
          description: A link to documentation about this error.
      required:
        - type
        - code
        - message
        - url
      description: Details about a specific error.
      title: Types.StatusCodes.RestApiErrorItem
    CXMLScriptUpdateStatusCode422:
      type: object
      properties:
        errors:
          type: array
          items:
            $ref: '#/components/schemas/Types.StatusCodes.RestApiErrorItem'
          description: List of validation errors.
      required:
        - errors
      description: The request contains invalid parameters. See errors for details.
      title: CXMLScriptUpdateStatusCode422
    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": "993ed018-9e79-4e50-b97b-984bd5534095",
  "project_id": "1313fe58-5e14-4c11-bbe7-6fdfa11fe780",
  "name": "Reception Script",
  "type": "cxml_script",
  "created_at": "2024-05-06T12:20:00Z",
  "updated_at": "2024-05-06T12:20:00Z",
  "cxml_script": {
    "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
    "contents": "<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response><Say>Hello World</Say></Response>",
    "request_count": 5,
    "last_accessed_at": "2023-10-01T12:00:00Z",
    "request_url": "https://example.signalwire.com/laml-bins/2537c89e-2606-48c2-b3c2-bb601d863d1e",
    "script_type": "calling",
    "display_name": "Booking Assistant Script",
    "status_callback_url": "https://example.com/cxml/status",
    "status_callback_method": "POST"
  }
}
```

## **Example**

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

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

updated = client.fabric.cxml_scripts.update("resource-id", display_name="updated-name")
print(f"Updated: {updated['name']}")
```