meta data for this page
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
api [2023/09/14 20:15] – created johnny | api [2025/06/09 15:26] (current) – added "API Reference Guide" dalton | ||
---|---|---|---|
Line 2: | Line 2: | ||
- | Use ITFlow' | + | Use ITFlow' |
- | The current version of the ITFlow API is v1. It can be accessed at **/ | + | The current version of the ITFlow API is v1. It can be accessed at **itflow.example.com/ |
+ | |||
+ | ===== Generating an API Key ===== | ||
+ | |||
+ | - Login and navigate to the **Admin Settings** page | ||
+ | - Select **API Keys** | ||
+ | - Select **Create** to open the New Key modal | ||
+ | - On Details tab, input the key name and expiration date. Select whether the key will allow access to all clients or a specific client | ||
+ | - On Keys tab, note down the API key and credential password and select the checkbox to confirm you've made a copy of the keys. You will not see these admin in the admin interface. | ||
+ | - Select Create to add the key into the database | ||
===== Modules with API support at present ===== | ===== Modules with API support at present ===== | ||
Line 10: | Line 19: | ||
* assets | * assets | ||
* certificates | * certificates | ||
+ | * clients | ||
* contacts | * contacts | ||
+ | * credentials (logins) | ||
* domains | * domains | ||
* networks | * networks | ||
Line 20: | Line 31: | ||
* read | * read | ||
- | * create (partial) | + | * create |
- | * update (partial) | + | * update |
+ | * delete // | ||
- | ===== Generating an API Key ===== | ||
- | |||
- | - Navigate to the Admin panel | ||
- | - Click on API | ||
- | - Click on New Key to generate a new key | ||
+ | * //We may also add archive// | ||
===== Request Methods ===== | ===== Request Methods ===== | ||
Line 45: | Line 53: | ||
==== Notes ==== | ==== Notes ==== | ||
- | * For read requests, 50 records are shown by default. This can be adjusted by supplying the limit and offset parameters. | + | * For read requests, 50 records are shown by default. This can be adjusted by supplying the '' |
- | * For POST requests, the client_id parameter is always required if the API key used has scope/ | + | * For POST requests, the '' |
+ | * Be sure to check your Apache/PHP error logs if you're running into issues | ||
==== API Docs/ | ==== API Docs/ | ||
- | Documentation / an example of how to use a module API endpoint is shown on that module' | + | Documentation / an example of how to use a module API endpoint is shown on that module' |
+ | |||
+ | |||
+ | |||
+ | ---- | ||
+ | |||
+ | |||
+ | ====== API Reference Guide ====== | ||
+ | |||
+ | **Current API v1 Endpoints, Authentication, | ||
+ | |||
+ | ===== Quick Start Guide ===== | ||
+ | |||
+ | ==== Your First API Call in 5 Minutes ==== | ||
+ | |||
+ | - **Generate API Key** | ||
+ | - Login to ITFlow as admin | ||
+ | - Navigate to **Admin > API** | ||
+ | - Click **New Key** | ||
+ | - Choose scope: **All Clients** (for testing) or **Specific Client** | ||
+ | - Copy the generated key | ||
+ | |||
+ | - **Test Connection** | ||
+ | <code bash> | ||
+ | curl " | ||
+ | </ | ||
+ | |||
+ | - **Expected Response** | ||
+ | <code json> | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | ===== API Overview ===== | ||
+ | |||
+ | **Source**: ITFlow official documentation at docs.itflow.org/ | ||
+ | |||
+ | * **Base URL**: ''/ | ||
+ | * **Version**: | ||
+ | * **Authentication**: | ||
+ | * **Response Format**: JSON with '' | ||
+ | * **Pagination**: | ||
+ | * **Content-Type**: | ||
+ | * **Character Encoding**: UTF-8 (utf8mb4 in database) | ||
+ | |||
+ | ==== Standard Response Format ==== | ||
+ | |||
+ | **Source**: ITFlow official API documentation | ||
+ | |||
+ | <code json> | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | ] | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | ===== Authentication & Security ===== | ||
+ | |||
+ | ==== API Key Management ==== | ||
+ | |||
+ | * **Generation**: | ||
+ | * **Scoping Options**: | ||
+ | * **All Clients**: Full access to all client data | ||
+ | * **Specific Client**: Limited to single client ('' | ||
+ | * **Usage**: Query parameter ''? | ||
+ | * **Security**: | ||
+ | |||
+ | ==== Best Practices ==== | ||
+ | |||
+ | **Source**: MSP community recommendations and security standards | ||
+ | |||
+ | * **Rotate keys** regularly (monthly recommended) | ||
+ | * **Use client-scoped keys** for third-party integrations | ||
+ | * **Store keys securely** (environment variables, not code) | ||
+ | * **Monitor usage** via Apache/PHP logs | ||
+ | * **Use HTTPS only** for all API calls | ||
+ | |||
+ | ===== Currently Available Modules ===== | ||
+ | |||
+ | **Source**: ITFlow official API documentation confirms these modules have API support: | ||
+ | |||
+ | ==== Assets ''/ | ||
+ | |||
+ | **Purpose**: | ||
+ | |||
+ | **Source**: [[https:// | ||
+ | |||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | |||
+ | **Complete Fields** (from ITFlow Assets API Documentation): | ||
+ | |||
+ | <code json> | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | ==== Certificates ''/ | ||
+ | |||
+ | **Purpose**: | ||
+ | |||
+ | **Source**: [[https:// | ||
+ | |||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | |||
+ | **Complete Fields** (from ITFlow Certificates API Documentation): | ||
+ | |||
+ | <code json> | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | ==== Clients ''/ | ||
+ | |||
+ | **Purpose**: | ||
+ | |||
+ | **Source**: [[https:// | ||
+ | |||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | |||
+ | **Complete Fields** (from ITFlow Clients API Documentation): | ||
+ | |||
+ | <code json> | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | <wrap em>Note: Full field list is partially documented. The API returns numbered keys alongside named keys in the response format.</ | ||
+ | |||
+ | ==== Contacts ''/ | ||
+ | |||
+ | **Purpose**: | ||
+ | |||
+ | **Source**: ITFlow official API documentation lists contacts as supported module | ||
+ | |||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | |||
+ | **Available Fields**: Contact table structure includes fields like '' | ||
+ | |||
+ | ==== Credentials ''/ | ||
+ | |||
+ | **Purpose**: | ||
+ | |||
+ | **Source**: ITFlow official API documentation lists credentials (logins) as supported module | ||
+ | |||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | |||
+ | **Available Fields**: Database migration scripts confirm '' | ||
+ | |||
+ | ==== Domains ''/ | ||
+ | |||
+ | **Purpose**: | ||
+ | |||
+ | **Source**: [[https:// | ||
+ | |||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | |||
+ | **Complete Fields** (from ITFlow Domains API Documentation): | ||
+ | |||
+ | <code json> | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | ==== Networks ''/ | ||
+ | |||
+ | **Purpose**: | ||
+ | |||
+ | **Source**: ITFlow official API documentation lists networks as supported module | ||
+ | |||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | |||
+ | **Available Fields**: Database migration scripts show network interface relationships, | ||
+ | |||
+ | ==== Software ''/ | ||
+ | |||
+ | **Purpose**: | ||
+ | |||
+ | **Source**: ITFlow official API documentation lists software as supported module | ||
+ | |||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | |||
+ | **Status**: Module confirmed as available but dedicated documentation page not found. Database includes software table as confirmed by installation scripts. | ||
+ | |||
+ | ==== Tickets ''/ | ||
+ | |||
+ | **Purpose**: | ||
+ | |||
+ | **Source**: [[https:// | ||
+ | |||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | |||
+ | **Complete Fields** (from ITFlow Tickets API Documentation): | ||
+ | |||
+ | <code json> | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | <wrap em>Note: Full field list is partially documented. The API returns numbered keys alongside named keys in the response format.</ | ||
+ | |||
+ | ===== Current API Capabilities ===== | ||
+ | |||
+ | ==== Standard Operations (All Modules) ==== | ||
+ | |||
+ | * **READ**: Retrieve single record or list of records | ||
+ | * **CREATE**: Add new records with validation (partial support) | ||
+ | * **UPDATE**: Modify existing records (partial support) | ||
+ | * **DELETE**: Remove records (partial support) | ||
+ | |||
+ | ==== Query Parameters (read.php endpoints) ==== | ||
+ | |||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * API key required on all requests | ||
+ | |||
+ | ==== Response Format (Standardized) ==== | ||
+ | |||
+ | <code json> | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | { | ||
+ | // Record data with both numbered and named keys | ||
+ | } | ||
+ | ] | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | ===== Current Authentication ===== | ||
+ | |||
+ | ==== API Key Generation ==== | ||
+ | |||
+ | - Navigate to Admin panel in ITFlow | ||
+ | - Click on API section | ||
+ | - Click **New Key** to generate | ||
+ | - Choose scope: specific client or all clients | ||
+ | - Copy generated key for use | ||
+ | |||
+ | ==== API Key Usage ==== | ||
+ | |||
+ | * **Method**: Query parameter | ||
+ | * **Format**: ''? | ||
+ | * **Scope**: Can be limited to specific client or all clients | ||
+ | * **Access**: Currently all-or-nothing permissions | ||
+ | |||
+ | ==== Security Features ==== | ||
+ | |||
+ | * **Encrypted Storage**: API keys stored securely | ||
+ | * **Client Scoping**: Keys can be limited to specific clients | ||
+ | * **Access Logging**: API usage tracked in logs | ||
+ | |||
+ | ===== Current Limitations ===== | ||
+ | |||
+ | ==== Missing CRUD Operations ==== | ||
+ | |||
+ | * **UPDATE**: Limited support across modules | ||
+ | * **DELETE**: Limited support across modules | ||
+ | * **ARCHIVE**: | ||
+ | |||
+ | ==== Missing Advanced Features ==== | ||
+ | |||
+ | * **Bulk Operations**: | ||
+ | * **Advanced Search**: No full-text search or complex filtering | ||
+ | * **Webhooks**: | ||
+ | * **File Upload**: No direct file management API | ||
+ | * **Relationships**: | ||
+ | |||
+ | ==== Missing Business Modules ==== | ||
+ | |||
+ | * **Invoices/ | ||
+ | * **Quotes**: No sales proposal management | ||
+ | * **Time Tracking**: No billable hour recording | ||
+ | * **Calendar**: | ||
+ | * **Reports**: | ||
+ | |||
+ | ==== Authentication Limitations ==== | ||
+ | |||
+ | * **Granular Permissions**: | ||
+ | * **OAuth**: Only API key authentication available | ||
+ | |||
+ | ===== API Usage Examples ===== | ||
+ | |||
+ | ==== Get All Clients ==== | ||
+ | |||
+ | <code bash> | ||
+ | GET / | ||
+ | </ | ||
+ | |||
+ | ==== Get Specific Asset ==== | ||
+ | |||
+ | <code bash> | ||
+ | GET / | ||
+ | </ | ||
+ | |||
+ | ==== Create New Ticket ==== | ||
+ | |||
+ | <code bash> | ||
+ | POST / | ||
+ | Content-Type: | ||
+ | |||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | ==== List Client Assets ==== | ||
+ | |||
+ | <code bash> | ||
+ | GET / | ||
+ | </ | ||
+ | |||
+ | ===== Integration Capabilities ===== | ||
+ | |||
+ | ==== What Works Today ==== | ||
+ | |||
+ | * **Basic CRUD**: Create/read operations for core modules | ||
+ | * **Client Management**: | ||
+ | * **Asset Tracking**: Computer and equipment inventory | ||
+ | * **Ticket Creation**: Help desk ticket automation | ||
+ | * **Documentation**: | ||
+ | |||
+ | ==== What's Missing for Full Automation ==== | ||
+ | |||
+ | * **Financial Operations**: | ||
+ | * **Real-time Events**: No webhook triggers for automation | ||
+ | * **Bulk Data Sync**: No efficient mass data operations | ||
+ | * **File Management**: | ||
+ | * **Advanced Workflows**: | ||
+ | |||
+ | ===== Error Handling & Troubleshooting ===== | ||
+ | |||
+ | ==== Standard Error Codes ==== | ||
+ | |||
+ | **Source**: HTTP standard codes - ITFlow API observed behavior | ||
+ | |||
+ | * **200**: Success - Request completed successfully | ||
+ | * **400**: Bad Request - Invalid parameters or malformed request | ||
+ | * **401**: Unauthorized - Invalid or missing API key | ||
+ | * **403**: Forbidden - API key lacks required permissions | ||
+ | * **404**: Not Found - Endpoint or record doesn' | ||
+ | * **500**: Server Error - Internal ITFlow error | ||
+ | |||
+ | ==== Common Error Messages ==== | ||
+ | |||
+ | **Source**: Observed API responses | ||
+ | |||
+ | <code json> | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | ==== Troubleshooting Steps ==== | ||
+ | |||
+ | **Source**: Community experience and [[https:// | ||
+ | |||
+ | - **API Key Issues** | ||
+ | * Verify key is correct (copy/paste errors common) | ||
+ | * Check key scope (client-specific vs all clients) | ||
+ | * Confirm key hasn't been deactivated | ||
+ | |||
+ | - **Permission Errors** | ||
+ | * Add '' | ||
+ | * Verify client_id exists and is accessible | ||
+ | |||
+ | - **Server Errors** | ||
+ | * Check Apache/PHP error logs: ''/ | ||
+ | * Verify ITFlow database connectivity | ||
+ | * Check PHP memory limits for large requests | ||
+ | |||
+ | - **Data Issues** | ||
+ | * Validate required fields for POST requests | ||
+ | * Check data types (strings, integers, dates) | ||
+ | * Verify foreign key relationships exist | ||
+ | |||
+ | ==== Debug Mode ==== | ||
+ | |||
+ | **Source**: ITFlow admin settings and [[https:// | ||
+ | |||
+ | Enable PHP error reporting in ITFlow settings for detailed error messages during development. | ||
+ | |||
+ | ===== Integration Examples ===== | ||
+ | |||
+ | ==== PowerShell Examples ==== | ||
+ | |||
+ | **Source**: [[https:// | ||
+ | |||
+ | **List All Clients**: | ||
+ | |||
+ | <code powershell> | ||
+ | $apiKey = " | ||
+ | $baseUrl = " | ||
+ | $uri = " | ||
+ | |||
+ | Invoke-RestMethod -Uri $uri | ConvertTo-Json | ||
+ | </ | ||
+ | |||
+ | **Create New Asset**: | ||
+ | |||
+ | <code powershell> | ||
+ | $uri = " | ||
+ | $body = @{ | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ConvertTo-Json | ||
+ | |||
+ | Invoke-RestMethod -Method Post -Uri $uri -Body $body -ContentType " | ||
+ | </ | ||
+ | |||
+ | ==== PHP Examples ==== | ||
+ | |||
+ | <code php> | ||
+ | <?php | ||
+ | $api_key = ' | ||
+ | $base_url = ' | ||
+ | |||
+ | // Get clients | ||
+ | $url = $base_url . ' | ||
+ | $response = file_get_contents($url); | ||
+ | $data = json_decode($response, | ||
+ | |||
+ | print_r($data); | ||
+ | ?> | ||
+ | </ | ||
+ | |||
+ | ==== Python Examples ==== | ||
+ | |||
+ | <code python> | ||
+ | import requests | ||
+ | api_key = " | ||
+ | base_url = " | ||
- | Old API | + | # Get all clients |
+ | response = requests.get(f" | ||
+ | data = response.json() | ||
+ | print(data) | ||
- | The legacy ITFlow API is accessed at /api.php. We are working on moving all functionality into the new API at /api/. The legacy API has the following features: | + | # Create |
+ | ticket_data = { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
- | Caller ID lookup | + | response = requests.post(f" |
- | XML Phonebook Download - /api.php? | + | result |
- | Client Email (great for mailing lists) - / | + | print(result) |
- | | + | </code> |
- | Add new asset for a client - /api.php? | + | |
- | Required: api_key, client_id, add_asset (name) | + |