API Reference

Logic AI provides a comprehensive REST API that allows you to programmatically create, manage, and execute workflows. This reference documents the available endpoints, request formats, and response structures.

Authentication

All API requests must include authentication credentials.

API Keys

curl -X GET "https://api.logicai.com/v1/workflows" \
  -H "Authorization: Bearer YOUR_API_KEY"
  • API keys can be generated in the Logic AI dashboard under Settings > API Keys
  • Each key has specific permissions and can be restricted to certain operations
  • Keys should be treated as sensitive credentials and not exposed in client-side code

Base URL

All API endpoints use the following base URL:

https://api.logicai.com/v1

Response Format

All responses are returned in JSON format with the following structure:

{
  "success": true,
  "data": {
    // Response data varies by endpoint
  },
  "meta": {
    "requestId": "req_1234567890abcdef",
    "timestamp": "2023-10-25T12:34:56Z"
  }
}

Error responses use HTTP status codes and include error details:

{
  "success": false,
  "error": {
    "code": "invalid_request",
    "message": "Invalid workflow ID provided",
    "details": {
      "field": "workflow_id",
      "reason": "not_found"
    }
  },
  "meta": {
    "requestId": "req_1234567890abcdef",
    "timestamp": "2023-10-25T12:34:56Z"
  }
}

Rate Limits

  • The API has a default rate limit of 100 requests per minute
  • Enterprise plans have higher limits and custom rate limit options
  • Rate limit headers are included in all responses:
    • X-RateLimit-Limit: Maximum requests per minute
    • X-RateLimit-Remaining: Remaining requests in current window
    • X-RateLimit-Reset: Time (in seconds) until rate limit resets

Workflow Management

List Workflows

GET /workflows

Retrieves a list of workflows in your account.

Query Parameters

Parameter Type Description
limit int Maximum number of results (default: 20)
offset int Pagination offset (default: 0)
status string Filter by status (active, draft, archived)
sort string Sort field and direction (e.g., created_at:desc)

Response

{
  "success": true,
  "data": {
    "workflows": [
      {
        "id": "wf_1234567890abcdef",
        "name": "Customer Support Bot",
        "description": "Handles customer inquiries",
        "status": "active",
        "created_at": "2023-10-25T12:34:56Z",
        "updated_at": "2023-10-26T12:34:56Z"
      },
      // Additional workflows...
    ],
    "count": 2,
    "total": 42
  },
  "meta": {
    "requestId": "req_1234567890abcdef",
    "timestamp": "2023-10-25T12:34:56Z"
  }
}

Get Workflow

GET /workflows/{workflow_id}

Retrieves a single workflow by ID.

URL Parameters

Parameter Type Description
workflow_id string ID of the workflow

Response

{
  "success": true,
  "data": {
    "id": "wf_1234567890abcdef",
    "name": "Customer Support Bot",
    "description": "Handles customer inquiries",
    "status": "active",
    "components": [
      // Array of workflow components
    ],
    "connections": [
      // Array of component connections
    ],
    "variables": [
      // Array of workflow variables
    ],
    "created_at": "2023-10-25T12:34:56Z",
    "updated_at": "2023-10-26T12:34:56Z"
  },
  "meta": {
    "requestId": "req_1234567890abcdef",
    "timestamp": "2023-10-25T12:34:56Z"
  }
}

Create Workflow

POST /workflows

Creates a new workflow.

Request Body

{
  "name": "Customer Support Bot",
  "description": "Handles customer inquiries",
  "components": [
    // Array of workflow components
  ],
  "connections": [
    // Array of component connections
  ],
  "variables": [
    // Array of workflow variables
  ]
}

Response

{
  "success": true,
  "data": {
    "id": "wf_1234567890abcdef",
    "name": "Customer Support Bot",
    "description": "Handles customer inquiries",
    "status": "draft",
    "created_at": "2023-10-25T12:34:56Z",
    "updated_at": "2023-10-25T12:34:56Z"
  },
  "meta": {
    "requestId": "req_1234567890abcdef",
    "timestamp": "2023-10-25T12:34:56Z"
  }
}

Update Workflow

PATCH /workflows/{workflow_id}

Updates an existing workflow.

URL Parameters

Parameter Type Description
workflow_id string ID of the workflow

Request Body

{
  "name": "Updated Support Bot",
  "description": "Improved customer inquiry handling",
  "components": [
    // Updated array of workflow components
  ],
  "connections": [
    // Updated array of component connections
  ],
  "variables": [
    // Updated array of workflow variables
  ]
}

Response

{
  "success": true,
  "data": {
    "id": "wf_1234567890abcdef",
    "name": "Updated Support Bot",
    "description": "Improved customer inquiry handling",
    "status": "draft",
    "created_at": "2023-10-25T12:34:56Z",
    "updated_at": "2023-10-26T12:34:56Z"
  },
  "meta": {
    "requestId": "req_1234567890abcdef",
    "timestamp": "2023-10-26T12:34:56Z"
  }
}

Delete Workflow

DELETE /workflows/{workflow_id}

Deletes a workflow.

URL Parameters

Parameter Type Description
workflow_id string ID of the workflow

Response

{
  "success": true,
  "data": {
    "id": "wf_1234567890abcdef",
    "deleted": true
  },
  "meta": {
    "requestId": "req_1234567890abcdef",
    "timestamp": "2023-10-26T12:34:56Z"
  }
}

Workflow Execution

Execute Workflow

POST /workflows/{workflow_id}/execute

Executes a workflow with the provided input data.

URL Parameters

Parameter Type Description
workflow_id string ID of the workflow

Request Body

{
  "input": {
    "user_message": "I need help with my subscription",
    "user_id": "123456789",
    "additional_context": {
      "subscription_tier": "premium",
      "account_age_days": 120
    }
  },
  "options": {
    "timeout": 30,
    "async": false
  }
}

Response (Synchronous)

{
  "success": true,
  "data": {
    "execution_id": "exec_1234567890abcdef",
    "status": "completed",
    "result": {
      "response": "I can help with your premium subscription. What specific information do you need?",
      "detected_intent": "subscription_inquiry",
      "confidence": 0.92
    },
    "metrics": {
      "execution_time_ms": 850,
      "token_usage": {
        "prompt": 120,
        "completion": 35,
        "total": 155
      }
    },
    "started_at": "2023-10-26T12:34:56Z",
    "completed_at": "2023-10-26T12:34:57Z"
  },
  "meta": {
    "requestId": "req_1234567890abcdef",
    "timestamp": "2023-10-26T12:34:57Z"
  }
}

Response (Asynchronous)

{
  "success": true,
  "data": {
    "execution_id": "exec_1234567890abcdef",
    "status": "processing",
    "webhook_url": "https://api.logicai.com/v1/executions/exec_1234567890abcdef",
    "started_at": "2023-10-26T12:34:56Z"
  },
  "meta": {
    "requestId": "req_1234567890abcdef",
    "timestamp": "2023-10-26T12:34:56Z"
  }
}

Get Execution Status

GET /executions/{execution_id}

Retrieves the status and results of a workflow execution.

URL Parameters

Parameter Type Description
execution_id string ID of the execution

Response

{
  "success": true,
  "data": {
    "execution_id": "exec_1234567890abcdef",
    "workflow_id": "wf_1234567890abcdef",
    "status": "completed",
    "result": {
      "response": "I can help with your premium subscription. What specific information do you need?",
      "detected_intent": "subscription_inquiry",
      "confidence": 0.92
    },
    "metrics": {
      "execution_time_ms": 850,
      "token_usage": {
        "prompt": 120,
        "completion": 35,
        "total": 155
      }
    },
    "started_at": "2023-10-26T12:34:56Z",
    "completed_at": "2023-10-26T12:34:57Z"
  },
  "meta": {
    "requestId": "req_1234567890abcdef",
    "timestamp": "2023-10-26T12:35:00Z"
  }
}

Component Library

List Components

GET /components

Retrieves available components that can be used in workflows.

Query Parameters

Parameter Type Description
category string Filter by component category
type string Filter by component type
limit int Maximum number of results (default: 20)
offset int Pagination offset (default: 0)

Response

{
  "success": true,
  "data": {
    "components": [
      {
        "id": "comp_text_input",
        "name": "Text Input",
        "description": "Accepts text input from users",
        "category": "input",
        "type": "text",
        "schema": {
          // Component configuration schema
        },
        "inputs": [],
        "outputs": [
          {
            "name": "text",
            "type": "string",
            "description": "The input text"
          }
        ]
      },
      // Additional components...
    ],
    "count": 2,
    "total": 50
  },
  "meta": {
    "requestId": "req_1234567890abcdef",
    "timestamp": "2023-10-26T12:35:10Z"
  }
}

Usage & Analytics

Get Usage Statistics

GET /usage

Retrieves usage statistics for your account.

Query Parameters

Parameter Type Description
start_date string Start date (ISO format)
end_date string End date (ISO format)
breakdown string Breakdown dimension (day, workflow)

Response

{
  "success": true,
  "data": {
    "period": {
      "start": "2023-10-01T00:00:00Z",
      "end": "2023-10-31T23:59:59Z"
    },
    "executions": {
      "total": 12500,
      "breakdown": [
        {
          "date": "2023-10-01",
          "count": 350
        },
        // Additional days...
      ]
    },
    "token_usage": {
      "prompt": 2500000,
      "completion": 500000,
      "total": 3000000,
      "breakdown": [
        {
          "date": "2023-10-01",
          "prompt": 75000,
          "completion": 15000,
          "total": 90000
        },
        // Additional days...
      ]
    },
    "costs": {
      "total": 150.75,
      "currency": "USD",
      "breakdown": [
        {
          "date": "2023-10-01",
          "amount": 4.50
        },
        // Additional days...
      ]
    }
  },
  "meta": {
    "requestId": "req_1234567890abcdef",
    "timestamp": "2023-10-26T12:36:00Z"
  }
}

Webhooks

List Webhooks

GET /webhooks

Retrieves configured webhooks for your account.

Response

{
  "success": true,
  "data": {
    "webhooks": [
      {
        "id": "wh_1234567890abcdef",
        "url": "https://example.com/webhook",
        "events": ["workflow.execution.completed", "workflow.created"],
        "active": true,
        "created_at": "2023-10-20T12:34:56Z"
      },
      // Additional webhooks...
    ]
  },
  "meta": {
    "requestId": "req_1234567890abcdef",
    "timestamp": "2023-10-26T12:37:00Z"
  }
}

Create Webhook

POST /webhooks

Creates a new webhook subscription.

Request Body

{
  "url": "https://example.com/webhook",
  "events": ["workflow.execution.completed", "workflow.created"],
  "description": "Production webhook endpoint"
}

Response

{
  "success": true,
  "data": {
    "id": "wh_1234567890abcdef",
    "url": "https://example.com/webhook",
    "events": ["workflow.execution.completed", "workflow.created"],
    "active": true,
    "secret": "whsec_1234567890abcdefghijklmn",
    "created_at": "2023-10-26T12:37:30Z"
  },
  "meta": {
    "requestId": "req_1234567890abcdef",
    "timestamp": "2023-10-26T12:37:30Z"
  }
}

Versioning & Change Management

API versioning is controlled through the URL path (/v1). When breaking changes are introduced, a new version path will be created (e.g., /v2).

Deprecation Policy

  • APIs are deprecated with at least 6 months' notice
  • Deprecated features are marked in documentation and with response headers
  • Migration guides are provided for all deprecated features

SDKs & Client Libraries

Official client libraries are available for:

  • JavaScript/TypeScript
  • Python
  • Java
  • Go
  • Ruby
  • PHP

Visit our Developer Portal for SDK documentation, installation instructions, and code examples.

Additional Resources

For enterprise support and custom solutions, contact our sales team.

results matching ""

    No results matching ""