Getting Started

The GraphQL API is the primary way for third-party applications to read and write to the Worksome platform.

If you are unfamiliar with the GraphQL API, we recommend that you start by reading our “Introduction to GraphQL” guide.

To get started, you’ll need an API access token, you can learn about and generate one from the Authentication page. Once you’ve generated a token, carry on reading to learn how to use the API.

We also have extensive documentation for the API available on Apollo Studio, which is searchable and may be easier to use.

The GraphQL Endpoint

The GraphQL API has a single endpoint:

https://api.worksome.com/graphql

The endpoint is constant no matter what operation you perform.

This endpoint also functions as a GraphQL explorer, using the official GraphQL Playground. This can be used to test GraphQL queries, or use introspection to discover the API.

Making your first request

GraphQL requests to our API are made over HTTP, via the POST request method. All data is sent in JavaScript Object Notation (JSON) format.

We’ll be creating a GraphQL API request using the Laravel HTTP Client for this example.

use Illuminate\Support\Facades\Http;

$apiToken = env('WORKSOME_API_TOKEN');

// The query is a GraphQL structured request specifying what is needed.
$query = <<<GQL
    query {
      profile {
        name
        email
      }
    }
GQL;

// If necessary, parameters can also be provided to the query.
$parameters = [];

$response = Http::withToken($apiToken)
    ->post('https://api.worksome.com/graphql', [
        'query' => $query,
        'parameters' => $parameters,
    ])
    ->json();

dd($response);