> ## Documentation Index
> Fetch the complete documentation index at: https://vectorly-783efd43.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Invoke CloudFunctions

> This API is used to run various tasks: run sample, run analyze, run
CloudFunction.

The `target` parameter has two kinds of values:

- Cloud Function ID (e.g. `MARVIZPLOT`). In this case, the `action` parameter
  must be `run`. The content in `parameters` is defined by the specific Cloud
  Function.
- Workflow ID (e.g. `F46FF98D7`). In this case, the `action` parameter must be
  `run_sample` or `run_analyze`, and `parameters` should be empty or ignored.

The `get_response` parameter is used to indicate whether to synchronously and
wait for the response from the command. If set to `true`, the API will wait for
the command to finish and return the response. If set to `false`, the API will
return immediately after the command is started.

The return format is also defined by the specific Cloud Function.

Example:

1. Arivz plot in serverside

```json5
// curl -H "Authorization: Bearer $token" "$root/invoke" --json \
{
    "target": "MARVIZPLOT",
    "action": "run",
    "get_response": true,
    "parameters": {
        "experiment_id": "X7CED97DD",
        "return_type": "json",
        "plot_func": "plot_ecdf",
        "plot_chain": "chain#1",
        "plot_var": "σ/val"
    }
}

// OUTPUT
{"status": "ok", "data": {"cloudfunction_response": {<plotdata>}}}
```

2. Run sample
```json5
// curl -H "Authorization: Bearer $token" "$root/invoke" --json \
{
    "target": "F46FF98D7",
    "action": "run_sample",
    "get_response": true
}

// OUTPUT
{"status": "ok", "data": {"experiment_id": "XFF2F7F8B", "experiment_name": "priceless_elion"}}
```

3. Run Analyze

```json5
// curl -H "Authorization: Bearer $token" "$root/invoke" --json \
{
    "target": "F46FF98D7",
    "action": "run_analyze",
    "get_response": false
}

// OUTPUT
{"status": "ok", "data": {}}
```



## OpenAPI

````yaml post /invoke
openapi: 3.1.0
info:
  title: Coinfer Server API
  version: 0.0.1776236533+0db4b8c
  description: |+

    This part of document describes the HTTP APIs of the Coinfer cloud.

servers:
  - url: https://api.coinfer.ai
    description: The production environment
  - url: https://dev.coinfer.ai
    description: The development environment
security: []
tags:
  - name: Object
    description: APIs related to object CRUD operations.
  - name: Invoke
    description: APIs used to invoke CloudFunction or run workflow.
  - name: Notification
    description: APIs related to notification.
  - name: Authorization
    description: >-
      APIs related to user, token, login, etc.


      Normally APIs in this group should not be used. You should get API token
      from our website and then use the token to call other APIs.
paths:
  /invoke:
    post:
      tags:
        - Invoke
      summary: Invoke CloudFunctions
      description: >-
        This API is used to run various tasks: run sample, run analyze, run

        CloudFunction.


        The `target` parameter has two kinds of values:


        - Cloud Function ID (e.g. `MARVIZPLOT`). In this case, the `action`
        parameter
          must be `run`. The content in `parameters` is defined by the specific Cloud
          Function.
        - Workflow ID (e.g. `F46FF98D7`). In this case, the `action` parameter
        must be
          `run_sample` or `run_analyze`, and `parameters` should be empty or ignored.

        The `get_response` parameter is used to indicate whether to
        synchronously and

        wait for the response from the command. If set to `true`, the API will
        wait for

        the command to finish and return the response. If set to `false`, the
        API will

        return immediately after the command is started.


        The return format is also defined by the specific Cloud Function.


        Example:


        1. Arivz plot in serverside


        ```json5

        // curl -H "Authorization: Bearer $token" "$root/invoke" --json \

        {
            "target": "MARVIZPLOT",
            "action": "run",
            "get_response": true,
            "parameters": {
                "experiment_id": "X7CED97DD",
                "return_type": "json",
                "plot_func": "plot_ecdf",
                "plot_chain": "chain#1",
                "plot_var": "σ/val"
            }
        }


        // OUTPUT

        {"status": "ok", "data": {"cloudfunction_response": {<plotdata>}}}

        ```


        2. Run sample

        ```json5

        // curl -H "Authorization: Bearer $token" "$root/invoke" --json \

        {
            "target": "F46FF98D7",
            "action": "run_sample",
            "get_response": true
        }


        // OUTPUT

        {"status": "ok", "data": {"experiment_id": "XFF2F7F8B",
        "experiment_name": "priceless_elion"}}

        ```


        3. Run Analyze


        ```json5

        // curl -H "Authorization: Bearer $token" "$root/invoke" --json \

        {
            "target": "F46FF98D7",
            "action": "run_analyze",
            "get_response": false
        }


        // OUTPUT

        {"status": "ok", "data": {}}

        ```
      operationId: coinfer_apis_command_api_invoke
      parameters: []
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RunCommandReq'
        required: true
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                anyOf:
                  - $ref: '#/components/schemas/SuccRsp_Any_'
                  - $ref: '#/components/schemas/ErrRsp'
                title: Response
      security:
        - CommandAPIAuth: []
components:
  schemas:
    RunCommandReq:
      properties:
        target:
          description: Target object to perform the action on
          title: Target
          type: string
        action:
          description: Action to perform
          title: Action
          type: string
        parameters:
          additionalProperties: true
          description: Parameters for the command
          title: Parameters
          type: object
        get_response:
          default: false
          description: Whether to get the response from the command (Sync run)
          title: Get Response
          type: boolean
      required:
        - target
        - action
      title: RunCommandReq
      type: object
    SuccRsp_Any_:
      properties:
        status:
          const: ok
          title: Status
          type: string
        data:
          title: Data
      required:
        - status
        - data
      title: SuccRsp[Any]
      type: object
    ErrRsp:
      properties:
        status:
          const: error
          title: Status
          type: string
        code:
          title: Code
          type: string
        message:
          title: Message
          type: string
      required:
        - status
        - code
        - message
      title: ErrRsp
      type: object
  securitySchemes:
    CommandAPIAuth:
      type: http
      scheme: bearer

````