---
title: XTC API
icon: webhook
description: "Programmatic Access to XTC\n"
sidebar:
  order: 500
---

XTC provides an API to access to XTC resources and trigger operations from automated environments. This part provides remote access to load tests. This includes 

* listing and inspecting load tests,
* duplicating and executing load tests,
* downloading result and report archives, and
* uploading and deleting code archives.

Administrators can [manage API client credentials](#managing-api-client-credentials) in both organizations and projects. These credentials are used to [request a temporary access token](#requesting-an-access-token) needed for [API requests](#making-api-calls).

:::note
The API focuses on test execution, artifact management, and reporting. User, role, and organization configuration remain restricted to the web interface.
:::

## Managing API client credentials

To allow remote access to your load tests, you must first create client credentials. You can do this in your organization or in your projects.

To create client credentials in your organization, go to *Configuration* > *Integrations* > *API Client Credentials* and click *Add*. Specify a name, an optional expiration date, the target API version, and required scopes. Credentials with an expiration date expire at 23:59:59 UTC on the specified day.

![Dialog to add new client credentials to an organization.](/images/xtc/api_credentials_create.png)
*Dialog to add new client credentials to an organization.*

Submitting the dialog displays the generated client secret once. Copy and store it securely; XTC does not display it again. If you lose the secret, you must generate a new credential pair.

:::note
Client credentials cannot be modified. If you need different scopes or lifetimes, delete and recreate them.
:::

Client credentials defined at the organization level apply across all projects within that organization. You can turn off organization credentials for individual projects under *Configuration* > *Integrations* > *API Client Credentials*.

![Enabling or disabling organization credentials in a project.](/images/xtc/api_credentials_disableInProject.png)
*Enabling or disabling organization credentials in a project.*

In the same location, you can also create project-scoped credentials that restrict access exclusively to resources within that project.

Whether you use organization-level or project-level credentials depends on your security requirements.

## Requesting an access token

To authenticate API calls, request a temporary bearer token. The following example demonstrates this using `curl`:

```
curl -X POST \
     -d "client_id=<your-client-id>" \
     -d "client_secret=<your-client-secret>" \
     -d "grant_type=client_credentials" \
     -d "scope=LOADTEST_LIST LOADTEST_STATUS LOADTEST_DETAILS LOADTEST_COPY_RUN LOADTEST_REPORT_DOWNLOAD LOADTEST_RESULT_DOWNLOAD CODEARCHIVE_UPLOAD CODEARCHIVE_DELETE" \
     https://xtc.xceptance.com/oauth/token
```

As you can see, you need to pass both the client ID and secret, but also the grant type `client_credentials` and the scopes for which this token will be used. The scope list may contain fewer scopes than defined in the credentials, but no more (such as `CODEARCHIVE_UPLOAD` and `CODEARCHIVE_DELETE` for managing code archives).

Now run the curl command. XTC returns a JSON response containing an `access_token` field. This access token expires automatically after one hour, but you can request new tokens at any time. For detailed instructions on API-driven code archive uploads, see [Code Archives](/xtc/loadtesting/code-archives/).

## Making API calls

To make an initial API call, list all load tests in a project. Provide your access token and the short names of your organization and project (available in the organization or project configuration):

```sh
curl -X GET \
     -H "Authorization: Bearer <your-jwt-access-token>" \
     https://xtc.xceptance.com/public/api/v2/orgs/<org-short-name>/projects/<project-short-name>/loadTests
```

The response returns a JSON array of all configured load tests.

### Generating reports and downloading artifacts via API

The XTC API allows triggering custom report generation and downloading resulting artifacts programmatically:

#### Triggering report creation

Send a `POST` request to the project's reports endpoint:

```bash
curl -X POST \
     -H "Authorization: Bearer <your-jwt-access-token>" \
     -H "Content-Type: application/json" \
     -d '{
       "name": "Nightly Regression Steady-State",
       "resultId": 42,
       "noRampUp": true,
       "createPdf": true
     }' \
     https://xtc.xceptance.com/public/api/v2/orgs/<org-short-name>/projects/<project-short-name>/reports
```

- **`noRampUp`**: when `true`, excludes the test ramp-up phase to measure steady-state metrics.
- **`createPdf`**: when `true`, compiles an executive A4 PDF report (`load-report.pdf`).

#### Downloading report artifacts

Beyond downloading full `.tar.gz` report archives, you can retrieve individual artifacts directly:
- **Executive PDF**: `GET /public/api/v2/orgs/{org}/projects/{project}/reports/{reportId}/artifacts/load-report.pdf`
- **AI Data Report**: `GET /public/api/v2/orgs/{org}/projects/{project}/reports/{reportId}/artifacts/ai-data.md`

For a complete list of endpoints, schemas, and parameters, explore the interactive API Explorer:

## API documentation and explorer

For formal API specifications, visit https://xtc.xceptance.com/public/api/json or https://xtc.xceptance.com/public/api/yaml. Both endpoints provide [OpenAPI](https://www.openapis.org/)-compliant definitions of all endpoints, request bodies, and response payloads.

XTC also presents public APIs as interactive documentation in the [XTC API Explorer](https://xtc.xceptance.com/exploreApi), including descriptive help text and schema models.

![API Explorer displaying information about the load test details request.](/images/xtc/api_explorer.png)
*API Explorer displaying information about the load test details request.*

You can also execute API calls directly from the API Explorer. To authenticate, navigate to **Authentication** in the top navigation. Provide a bearer access token, or enter your client credentials and scopes to let the explorer create a token through OAuth.

![Handling authentication in the API explorer: an access token has been created for the entered client ID and secret.](/images/xtc/api_explorer_authentication.png)
*Handling authentication in the API explorer: an access token has been created for the entered client ID and secret.*

## API versions

The XTC API uses semantic versioning. The stable API version is marked in the API Explorer. An API version can also carry a _Preview_ tag to indicate that endpoints, URL formats, and schemas remain subject to change.

To switch between API versions in the API Explorer, choose the desired version from the selector in the upper-right corner.

![The API version switch.](/images/xtc/api_explorer_versions.png)
*The API version switch.*
