The Workspace API is a GraphQL API that provides access to your workspace data within the Allfred.io workspace. This documentation describes how to connect to the API, authenticate, and perform queries to retrieve the necessary data.
Getting Started
Prerequisites
Before you begin using the Workspace API, you must meet the following prerequisites:
Have an Allfred.io account with Admin role
Request API access for your account
Obtaining API Access
Contact [email protected] to request API access for your user
Specify that the user must have the Admin role
Upon approval, you will receive a Bearer token to use for authorization
Authentication
Use the Bearer token in the HTTP request header for authentication:
Authorization: Bearer your_token
Technical Details
Endpoint:
https://{your-workspace}-api.allfred.io/workspace-api
Method: POST
Content-Type: application/json
Replace {your-workspace}
with your organization’s actual workspace name in Allfred.io. For example, if your workspace is called “demo”, the endpoint would be https://demo-api.allfred.io/workspace-api
.
Data Format Specifics
Time values: All time values are stored in seconds
Amounts: All amounts are stored as integers without decimal points. To get the actual amount, divide the value by 100.
Example: If an invoice amount is returned as
12500
, the actual amount is 125.00
Accessing API Schema
You can retrieve the complete API schema with all available types, queries, and fields using GraphQL’s introspection feature. To get the schema:
Using GraphQL Introspection Query:
query { __schema { types { name kind description fields { name description type { name kind } } } }
Using GraphQL Clients:
Most GraphQL clients (like GraphiQL, Insomnia, Postman) automatically detect and provide schema documentation when you connect to the API endpoint with proper authentication
After connecting, you’ll have access to a documentation explorer showing all available types, queries, and fields
Documentation in Code:
The API includes descriptions of various types and fields directly in the schema
You can see these descriptions when browsing the schema in a GraphQL client or IDE
Available Queries
The Workspace API provides the following queries:
User Queries
me
Returns information about the currently authenticated user.
Example 1 (Simple):
{ me { id first_name last_name } }
Example 2 (More detailed):
{ me { id first_name last_name email codename team { id name } roles { id name } } }
user(id: ID!)
Returns detailed information about a specific user.
Example 1 (Simple):
{ user(id: 6) { id first_name last_name } }
Example 2 (More detailed):
{ user(id: 6) { id first_name last_name email display_name team { id name } } }
users
Returns a list of all users with pagination support.
Example 1 (Simple):
{ users(first: 10) { data { id first_name last_name } } }
Example 2 (More detailed):
{ users( first: 10 page: 1 filters: { orderBy: { column: FULL_NAME order: ASC } } ) { paginatorInfo { count currentPage total } data { id first_name last_name email team { name } } } }
Brand Queries
brand(id: ID)
Returns detailed information about a specific brand.
Example 1 (Simple):
{ brand(id: 123) { id name code } }
Example 2 (More detailed):
{ brand(id: 123) { id name code created_at archived_at client { id name } } }
brands
Returns a list of all brands with pagination, filtering, and sorting.
Example 1 (Simple):
{ brands(first: 10) { data { id name code } } }
Example 2 (More detailed):
{ brands( first: 15 page: 1 filters: { orderBy: { column: BRAND_NAME order: DESC } } ) { paginatorInfo { count total } data { id name code client { name } responsiblePerson { first_name last_name } } } }
Project Queries
project(id: ID)
Returns detailed information about a specific project.
Example 1 (Simple):
{ project(id: 456) { id title code } }
Example 2 (More detailed):
{ project(id: 456) { id title code start_date expected_end_date status brand { id name } } }
projects
Returns a list of all projects with pagination support.
Example 1 (Simple):
{ projects(first: 10) { data { id title code } } }
Example 2 (More detailed):
{ projects( first: 20 page: 1 filters: { where: { column: STATUS value: "active" } orderBy: { column: PROJECT_TITLE order: ASC } } ) { paginatorInfo { count total } data { id title code start_date status brand { name } } } }
Task Queries
task(id: ID!)
Returns detailed information about a specific task.
Example 1 (Simple):
{ task(id: 789) { id name planned_time } }
Example 2 (More detailed):
{ task(id: 789) { id name planned_time deadline billable status { id name system_status } } }
tasks
Returns a list of all tasks with pagination support.
Example 1 (Simple):
{ tasks(first: 10) { data { id name deadline } } }
Example 2 (More detailed):
{ tasks( first: 20 page: 1 filters: { where: { column: PROJECT_ID value: 42 } orderBy: { column: DEADLINE order: ASC } } ) { paginatorInfo { count total } data { id name deadline planned_time status { name } } } }
Request for Invoicing Queries
requestForInvoicing(id: ID)
Returns detailed information about a specific Request for Invoicing (RFI).
Example 1 (Simple):
{ requestForInvoicing(id: 101) { id status type } }
Example 2 (More detailed):
{ requestForInvoicing(id: 101) { id status type issue_date due_date client { id name } } }
requestsForInvoicing
Returns a list of all Requests for Invoicing with pagination support.
Example 1 (Simple):
{ requestsForInvoicing(first: 10) { data { id status type } } }
Example 2 (More detailed):
{ requestsForInvoicing( first: 15 page: 1 filters: { where: { column: STATUS value: "SUBMITTED" } orderBy: { column: CREATED_AT order: DESC } } ) { paginatorInfo { count total } data { id status type created_at stats { total_amount } } } }
Outgoing Invoice Queries
outgoingInvoice(id: ID)
Returns detailed information about a specific Outgoing Invoice (OI).
Example 1 (Simple):
{ outgoingInvoice(id: 202) { id invoice_no type } }
Example 2 (More detailed):
{ outgoingInvoice(id: 202) { id invoice_no type issue_date due_date paid_at client { name } } }
outgoingInvoices
Returns a list of all Outgoing Invoices with pagination support.
Example 1 (Simple):
{ outgoingInvoices(first: 10) { data { id invoice_no issue_date } } }
Example 2 (More detailed):
{ outgoingInvoices( first: 15 page: 1 filters: { where: { column: PAYMENT_STATUS value: "unpaid" } orderBy: { column: DUE_DATE order: ASC } } ) { paginatorInfo { count total } data { id invoice_no issue_date due_date stats { total_amount_with_vat_in_currency } } } }
Outgoing Proforma Invoice Queries
outgoingProformaInvoice(id: ID)
Returns detailed information about a specific Outgoing Proforma Invoice (OPI).
Example 1 (Simple):
{ outgoingProformaInvoice(id: 303) { id invoice_no issue_date } }
Example 2 (More detailed):
{ outgoingProformaInvoice(id: 303) { id invoice_no issue_date due_date paid_at client { name } } }
outgoingProformaInvoices
Returns a list of all Outgoing Proforma Invoices with pagination support.
Example 1 (Simple):
{ outgoingProformaInvoices(first: 10) { data { id invoice_no issue_date } } }
Example 2 (More detailed):
{ outgoingProformaInvoices( first: 15 page: 1 filters: { where: { column: BRAND_ID value: 42 } orderBy: { column: ISSUE_DATE order: DESC } } ) { paginatorInfo { count total } data { id invoice_no issue_date due_date stats { unused_amount_in_currency } } } }
Time Tracking Queries
timeTrackingItem(id: ID!)
Returns detailed information about a specific Time Tracking item.
Example 1 (Simple):
{ timeTrackingItem(id: 404) { id tracked_time tracked_for_date } }
Example 2 (More detailed):
{ timeTrackingItem(id: 404) { id tracked_time tracked_for_date note billable user { first_name last_name } } }
timeTrackingItems(from: Date!, to: Date!, user_id: ID)
Returns a list of all Time Tracking items in a date range, optionally filtered by user.
Example 1 (Simple):
{ timeTrackingItems( from: "2025-01-01" to: "2025-01-31" ) { id tracked_time tracked_for_date } }
Example 2 (More detailed):
{ timeTrackingItems( from: "2025-01-01" to: "2025-01-31" user_id: 42 ) { id tracked_time tracked_for_date note billable project { title code } } }
Expense Queries
expense(id: ID!)
Returns detailed information about a specific Expense.
Example 1 (Simple):
{ expense(id: 505) { id status type } }
Example 2 (More detailed):
{ expense(id: 505) { id status type issue_date due_date paid_at document_number total_amount_with_vat_in_currency } }
expenses
Returns a list of all Expenses with pagination support.
Example 1 (Simple):
{ expenses(first: 10) { data { id status type } } }
Example 2 (More detailed):
{ expenses( first: 15 page: 1 filters: { where: { column: STATUS value: "APPROVED" } orderBy: { column: DUE_DATE order: ASC } } ) { paginatorInfo { count total } data { id status type issue_date due_date contractor { legal_name } } } }
Working with Pagination
Most queries that return multiple items support pagination. The response includes both the data array and a paginatorInfo object with pagination metadata.
Example of using pagination:
{ users(first: 10, page: 2) { paginatorInfo { count # Number of items on current page currentPage # Current page number hasMorePages # Are there more pages? lastPage # Last page number total # Total number of items across all pages perPage # Items per page } data { id first_name last_name } } }
Filtering and Sorting
Most list queries support filtering and sorting using the filters
and orderBy
parameters.
Example of filtering and sorting:
{ projects( filters: { where: { column: STATUS operator: EQ value: "active" } search: "marketing" # Free text search orderBy: { column: PROJECT_TITLE order: ASC } } ) { data { id title code } } }
Sample Code
PHP Example
<?php function query_workspace_api($query, $variables = []) { $url = 'https://{your-workspace}-api.allfred.io/workspace-api'; $headers = [ 'Content-Type: application/json', 'Authorization: Bearer YOUR_TOKEN' ]; $data = [ 'query' => $query ]; if (!empty($variables)) { $data['variables'] = $variables; } $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data)); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); $response = curl_exec($ch); if (curl_error($ch)) { throw new Exception(curl_error($ch)); } curl_close($ch); return json_decode($response, true); } // Example: Get active projects for a specific brand function get_projects($brandId) { $query = ' query GetProjects($brandId: ID!) { projects( first: 10 filters: { where: { column: BRAND_ID value: $brandId } orderBy: { column: PROJECT_TITLE order: ASC } } ) { data { id title code start_date } } } '; $variables = [ 'brandId' => $brandId ]; try { $result = query_workspace_api($query, $variables); return $result['data']['projects']['data']; } catch (Exception $e) { echo 'Error fetching projects: ' . $e->getMessage(); return []; } } // Usage $projects = get_projects('42'); print_r($projects);
CURL Example
# Basic query example (get user info) curl -X POST \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_TOKEN" \ -d '{"query": "{ me { id first_name last_name email } }"}' \ https://{your-workspace}-api.allfred.io/workspace-api # Example with variables (get tasks for a project) curl -X POST \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_TOKEN" \ -d '{ "query": "query GetTasks($projectId: ID!) { tasks(first: 10, filters: { where: { column: PROJECT_ID, value: $projectId } }) { data { id name deadline } } }", "variables": { "projectId": "123" } }' \ https://{your-workspace}-api.allfred.io/workspace-api
Postman Example
Create a new request in Postman
Set the request method to POST
Enter the URL:
https://{your-workspace}-api.allfred.io/workspace-api
In the Headers tab, add:
Content-Type: application/json
Authorization: Bearer YOUR_TOKEN
In the Body tab:
Select “raw” and “JSON”
Enter your GraphQL query in the following format:
{ "query": "{ projects(first: 5) { data { id title code } } }" }
For queries with variables, use this format:
{ "query": "query GetProject($id: ID!) { project(id: $id) { id title code start_date } }", "variables": { "id": "456" } }
Click Send to execute the request
Support
If you encounter any issues or have questions about the Workspace API, please contact [email protected].