> ## Documentation Index
> Fetch the complete documentation index at: https://docs.salesive.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a script

> Create a custom storefront script for an integration. Requires the WRITE_SCRIPTS scope.

Creates a script from the integration id, code and enabled flag. The store is bound to your app token server-side — never send a shop id.


## OpenAPI

````yaml POST /scripts
openapi: 3.1.0
info:
  title: Salesive Apps API — Productivity
  version: 1.0.0
  description: >-
    Manage the store's productivity resources from an installed third-party app:
    tasks (with recurrence and per-occurrence responses), notes, custom
    storefront scripts/tracking, and storefront comment replies. Every endpoint
    authenticates with an installed-app access token (prefix `app_`) and
    requires a specific OAuth scope. The target store is bound to the token
    server-side from the installation — never send a shop id.
servers:
  - url: https://api.salesive.com/api/v1
    description: Production
security:
  - AppToken: []
paths:
  /scripts:
    post:
      tags:
        - Scripts
      summary: Create a script
      description: >-
        Creates a custom storefront script for an integration. Authenticate with
        `Authorization: Bearer app_<token>`. Requires the `WRITE_SCRIPTS` scope
        and returns 403 if missing. The store is bound to the app token
        server-side from the installation — never send a shop id.
      operationId: createScript
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                integration:
                  type: string
                  description: The integration id this script belongs to.
                code:
                  type: string
                  description: The script/tracking code to inject into the storefront.
                enabled:
                  type: boolean
                  description: Whether the script is active.
            example:
              integration: 66e0aabbccddeeff00112233
              code: <script>console.log('hi');</script>
              enabled: true
      responses:
        '201':
          description: The created script.
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/EnvelopeBase'
                  - type: object
                    properties:
                      data:
                        $ref: '#/components/schemas/Script'
              example:
                status: 201
                success: true
                message: Script created
                data:
                  _id: 66e1f0a3c2d4e5f6a7b8c9d0
                  integration: 66e0aabbccddeeff00112233
                  code: <script>console.log('hi');</script>
                  enabled: true
                  shop: 6680aabbccddeeff00112200
                  createdAt: '2026-06-21T10:30:00.000Z'
                  updatedAt: '2026-06-21T10:30:00.000Z'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
components:
  schemas:
    EnvelopeBase:
      type: object
      description: >-
        Standard Salesive response envelope. The operation-specific payload is
        carried in `data`.
      required:
        - status
        - success
        - message
      properties:
        status:
          type: integer
          description: HTTP status code, echoed in the body.
        success:
          type: boolean
          description: Whether the request succeeded.
        message:
          type: string
          description: Human-readable result message.
    Script:
      type: object
      description: A custom storefront script/tracking snippet belonging to the store.
      properties:
        _id:
          type: string
        integration:
          type: string
          description: The integration id this script belongs to.
        code:
          type: string
          description: The script/tracking code injected into the storefront.
        enabled:
          type: boolean
        shop:
          type: string
          description: The store id (bound server-side).
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
    Envelope:
      allOf:
        - $ref: '#/components/schemas/EnvelopeBase'
        - type: object
          properties:
            data:
              description: Operation-specific payload (object, array, or null).
  responses:
    Unauthorized:
      description: Missing or invalid app access token.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Envelope'
          example:
            status: 401
            success: false
            message: Authentication required
            data: null
    Forbidden:
      description: The app token is missing the OAuth scope required for this operation.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Envelope'
          example:
            status: 403
            success: false
            message: Insufficient scope
            data: null
  securitySchemes:
    AppToken:
      type: http
      scheme: bearer
      description: >-
        Installed-app access token (prefix app_), issued by the OAuth install
        flow. The store is bound to the token server-side — never send a shop
        id.

````