AppMage

PlaybookRpc

PlaybookRpc provides the public RPC interface for listing, searching, reading, creating, updating, deleting, and managing resource uploads for playbooks. The methods exposed here are JSON-RPC style endpoints invoked through POST /api/rpc.

Endpoints

POST /api/rpc (Method: PlaybookRpc.list)

  • Description: List all playbooks available to the current subscription.

  • Request Body:

    {
      "method": "PlaybookRpc.list",
      "params": {
        "tags": ["example"],
        "limit": 50,
        "page": 1,
        "pageSize": 20,
        "filter": {},
        "sort": {}
      }
    }
  • Parameters:

    Name Type Required Description
    tags String[] No Optional tag filter. When omitted, the method also checks filter.tags if present.
    limit Number No Maximum number of playbooks to return.
    page Number No Accepted by the schema for RpcDataProvider-style calls, but not used by the method implementation.
    pageSize Number No Used as a fallback for limit when limit is not provided.
    filter Object No Accepted by the schema for RpcDataProvider-style calls. The implementation reads filter.tags when tags is not provided.
    sort Object No Accepted by the schema for RpcDataProvider-style calls, but not used by the method implementation.
  • Response:

    {
      "success": true,
      "data": {
        "data": [],
        "totalCount": 0
      }
    }

    The data array contains the results returned by the underlying playbook listing logic. totalCount is set to the number of returned results.

  • Example (cURL):

    curl -X POST "${APP_BASE_URL}/api/rpc" \
      -H "Content-Type: application/json" \
      -d '{
        "method": "PlaybookRpc.list",
        "params": {
          "tags": ["example"],
          "limit": 50
        }
      }'

POST /api/rpc (Method: PlaybookRpc.search)

  • Description: Search playbooks by keyword and/or tags.

  • Request Body:

    {
      "method": "PlaybookRpc.search",
      "params": {
        "query": "demo",
        "tags": ["example"],
        "limit": 10
      }
    }
  • Parameters:

    Name Type Required Description
    query String No Optional search keyword.
    tags String[] No Optional tag filter.
    limit Number No Optional result limit.
  • Response:

    {
      "success": true,
      "data": {
        "data": [],
        "totalCount": 0
      }
    }

    The data array contains the matched playbooks. totalCount is set to the number of returned results.

  • Example (cURL):

    curl -X POST "${APP_BASE_URL}/api/rpc" \
      -H "Content-Type: application/json" \
      -d '{
        "method": "PlaybookRpc.search",
        "params": {
          "query": "demo",
          "tags": ["example"],
          "limit": 10
        }
      }'

POST /api/rpc (Method: PlaybookRpc.findById)

  • Description: Get a single playbook by ID.

  • Request Body:

    {
      "method": "PlaybookRpc.findById",
      "params": {
        "_id": "playbook-id"
      }
    }
  • Parameters:

    Name Type Required Description
    _id String Yes The playbook identifier.
  • Response:

    {
      "success": true,
      "data": {
        "_id": "playbook-id"
      }
    }

    The method returns the playbook object when found. If no playbook exists for the provided ID, it throws an error with the message Playbook <id> not found.

  • Example (cURL):

    curl -X POST "${APP_BASE_URL}/api/rpc" \
      -H "Content-Type: application/json" \
      -d '{
        "method": "PlaybookRpc.findById",
        "params": {
          "_id": "playbook-id"
        }
      }'

POST /api/rpc (Method: PlaybookRpc.create)

  • Description: Create a new playbook.

  • Request Body:

    {
      "method": "PlaybookRpc.create",
      "params": {
        "...": "fields defined by the playbook schema"
      }
    }
  • Parameters:

    The request body is validated by PlaybookSchema with _id, subscriptionId, source, createdAt, and updatedAt omitted. The exact writable fields are defined by that schema and are not fully visible in this file.

    Name Type Required Description
    data Object Yes Playbook fields accepted by the schema after omitting the system-managed fields.
  • Response:

    {
      "success": true,
      "data": {}
    }

    The method returns the result of the underlying playbook creation logic.

  • Example (cURL):

    curl -X POST "${APP_BASE_URL}/api/rpc" \
      -H "Content-Type: application/json" \
      -d '{
        "method": "PlaybookRpc.create",
        "params": {
          "...": "fields defined by the playbook schema"
        }
      }'

POST /api/rpc (Method: PlaybookRpc.update)

  • Description: Update an existing playbook.

  • Request Body:

    {
      "method": "PlaybookRpc.update",
      "params": {
        "_id": "playbook-id",
        "data": {}
      }
    }
  • Parameters:

    Name Type Required Description
    _id String Yes The playbook identifier.
    data Object Yes Update payload passed through to the underlying playbook update logic.
  • Response:

    {
      "success": true,
      "data": {}
    }

    The method returns the result of the underlying playbook update logic.

  • Example (cURL):

    curl -X POST "${APP_BASE_URL}/api/rpc" \
      -H "Content-Type: application/json" \
      -d '{
        "method": "PlaybookRpc.update",
        "params": {
          "_id": "playbook-id",
          "data": {
            "title": "Updated title"
          }
        }
      }'

POST /api/rpc (Method: PlaybookRpc.delete)

  • Description: Delete a playbook.

  • Request Body:

    {
      "method": "PlaybookRpc.delete",
      "params": {
        "_id": "playbook-id"
      }
    }
  • Parameters:

    Name Type Required Description
    _id String Yes The playbook identifier.
  • Response:

    {
      "success": true,
      "data": {}
    }

    The method returns the result of the underlying playbook deletion logic.

  • Example (cURL):

    curl -X POST "${APP_BASE_URL}/api/rpc" \
      -H "Content-Type: application/json" \
      -d '{
        "method": "PlaybookRpc.delete",
        "params": {
          "_id": "playbook-id"
        }
      }'

POST /api/rpc (Method: PlaybookRpc.getResourceUploadKey)

  • Description: Get an upload key for uploading resource files to a playbook.

  • Request Body:

    {
      "method": "PlaybookRpc.getResourceUploadKey",
      "params": {
        "playbookId": "playbook-id"
      }
    }
  • Parameters:

    Name Type Required Description
    playbookId String Yes The playbook identifier used when requesting the upload key.
  • Response:

    {
      "success": true,
      "data": {}
    }

    The method returns the result of the underlying upload-key generation logic.

  • Example (cURL):

    curl -X POST "${APP_BASE_URL}/api/rpc" \
      -H "Content-Type: application/json" \
      -d '{
        "method": "PlaybookRpc.getResourceUploadKey",
        "params": {
          "playbookId": "playbook-id"
        }
      }'

POST /api/rpc (Method: PlaybookRpc.finalizeResourceUpload)

  • Description: Finalize resource upload — attach uploaded files to the playbook record.

  • Request Body:

    {
      "method": "PlaybookRpc.finalizeResourceUpload",
      "params": {
        "playbookId": "playbook-id",
        "uploadKey": "upload-key"
      }
    }
  • Parameters:

    Name Type Required Description
    playbookId String Yes The playbook identifier that will receive the uploaded file records.
    uploadKey String Yes The upload key used to finalize the pending file upload.
  • Response:

    {
      "success": true,
      "data": {
        "success": true,
        "added": 0
      }
    }

    If the finalized upload contains no files, the method returns { success: true, added: 0 }. When files are present, it appends resource records to the playbook and returns { success: true, added: <number>, files: [...] }, where the files array contains normalized resource entries with fileId, fileName, mimeType, and size.

  • **Example (cURL):