Create and manage organizations in your account. You use organizations to group together related projects. For example, you can use an organization to group together projects within a business unit or division.
Harness APIs (1.0)
The Harness Software Delivery Platform uses OpenAPI Specification v3.0. Harness constantly improves these APIs. Please be aware that some improvements could cause breaking changes.
The Harness API allows you to integrate and use all the services and modules we provide on the Harness Platform. If you use client-side SDKs, Harness functionality can be integrated with your client-side automation, helping you reduce manual efforts and deploy code faster.
For more information about how Harness works, visit the Harness Developer Hub.
The Harness API is a RESTful API that uses standard HTTP verbs. You can send requests in JSON, YAML, or form-data format. The format of the response matches the format of your request. You must send a single request at a time and ensure that you include your authentication key. For more information about this, go to Authentication.
Before you start integrating, get to know our API better by reading the following topics:
The methods you need to integrate with depend on the functionality you want to use. Work with your Harness Solutions Engineer to determine which methods you need.
To authenticate with the Harness API, you need to:
- Generate an API token on the Harness Platform.
- Send the API token you generate in the
x-api-key
header in each request.
To generate an API token, complete the following steps:
- Go to the Harness Platform.
- On the left-hand navigation, click My Profile.
- Click +API Key, enter a name for your key and then click Save.
- Within the API Key tile, click +Token.
- Enter a name for your token and click Generate Token. Important: Make sure to save your token securely. Harness does not store the API token for future reference, so make sure to save your token securely before you leave the page.
Send the token you created in the Harness Platform in the x-api-key header. For example: x-api-key: YOUR_API_KEY_HERE
The structure for each request and response is outlined in the API documentation. We have examples in JSON and YAML for every request and response. You can use our online editor to test the examples.
Field Name | Type | Default | Description |
---|---|---|---|
identifier | string | none | URL-friendly version of the name, used to identify a resource within it's scope and so needs to be unique within the scope. |
name | string | none | Human-friendly name for the resource. |
org | string | none | Limit to provided org identifiers. |
project | string | none | Limit to provided project identifiers. |
description | string | none | More information about the specific resource. |
tags | map[string]string | none | List of labels applied to the resource. |
order | string | desc | Order to use when sorting the specified fields. Type: enum(asc,desc). |
sort | string | none | Fields on which to sort. Note: Specify the fields that you want to use for sorting. When doing so, consider the operational overhead of sorting fields. |
limit | int | 30 | Pagination: Number of items to return. |
page | int | 1 | Pagination page number strategy: Specify the page number within the paginated collection related to the number of items in each page. |
created | int64 | none | Unix timestamp that shows when the resource was created (in milliseconds). |
updated | int64 | none | Unix timestamp that shows when the resource was last edited (in milliseconds). |
Harness uses conventional HTTP status codes to indicate the status of an API request. Generally, 2xx responses are reserved for success and 4xx status codes are reserved for failures. A 5xx response code indicates an error on the Harness server.
Error Code | Description |
---|---|
200 | OK |
201 | Created |
202 | Accepted |
204 | No Content |
400 | Bad Request |
401 | Unauthorized |
403 | Forbidden |
412 | Precondition Failed |
415 | Unsupported Media Type |
500 | Server Error |
To view our error response structures, go here.
The current version of our Beta APIs is yet to be announced. The version number will use the date-header format and will be valid only for our Beta APIs.
All our beta APIs are versioned as a Generation, and this version is included in the path to every API resource. For example, v1 beta APIs begin with app.harness.io/v1/
, where v1 is the API Generation.
The version number represents the core API and does not change frequently. The version number changes only if there is a significant departure from the basic underpinnings of the existing API. For example, when Harness performs a system-wide refactoring of core concepts or resources.
We use pagination to place limits on the number of responses associated with list endpoints. Pagination is achieved by the use of limit query parameters. The limit defaults to 30. Its maximum value is 100.
Following are the pagination headers supported in the response bodies of paginated APIs:
- X-Total-Elements : Indicates the total number of entries in a paginated response.
- X-Page-Number : Indicates the page number currently returned for a paginated response.
- X-Page-Size : Indicates the number of entries per page for a paginated response.
For example:
X-Total-Elements : 30
X-Page-Number : 0
X-Page-Size : 10
https://apidocs.harness.io/_mock/openapi-merged/
https://app.harness.io/
https://{vanity}/
- Mock server
https://apidocs.harness.io/_mock/openapi-merged/iacm/api/orgs/{org}/projects/{project}/workspaces/{identifier}
- Harness host URL
https://app.harness.io/iacm/api/orgs/{org}/projects/{project}/workspaces/{identifier}
- Vanity URL
https://app.harness.io/iacm/api/orgs/{org}/projects/{project}/workspaces/{identifier}
- curl
- JavaScript
- Node.js
- Python
- Java
- C#
- PHP
- Go
- Ruby
- R
- Payload
curl -i -X GET \
https://apidocs.harness.io/_mock/openapi-merged/iacm/api/orgs/4cv/projects/g7/workspaces/4o \
-H 'Harness-Account: rx' \
-H 'x-api-key: YOUR_API_KEY_HERE'
OK response.
Account is the internal customer account ID.
AssociatedTemplate defines the template details with template_id and version.
cost_breakdown_json is the identifier to the breakdown cost file from the current execution that was applied successfully
cost_diff_json is the identifier to the diff cost file between the previous and current successful executions
define if cost estimation operations will be performed in this workspace
Created is the unix timestamp at which the resource was originally created in milliseconds.
List of default pipelines associated with this workspace and any per-workspace overrides.
Description provides long-form text about the resource.
list of environment variables configured on the workspace.
modules_json is the identifier of any modules metadata associated with this workspace
Name is the human readable name for the resource.
Provider Connector is the reference to the connector for the infrastructure provider.
define an array of provider connectors that belong to Workspace
providers_json is the identifier of any modules metadata associated with this workspace
Provisioner Version defines the tool version to use.
prune_sensitive_data is a flag to enable or disable pruning of sensitive data
Repository is the name of the repository to use.
Repository Commit/Tag in which the code should be accessed.
Repository Connector is the reference to the connector to use for this code.
Repository Path is the path in which the infra code resides.
repository_submodules is the instruction about whether to clone submodules in the pipeline step
List of patterens that will be used for sparse checkout option of git clone
state_checksum is the sha-256 checksum of terraform state file
The status of the workspace
terraform_plan_json is the identifier to the current state file only in JSON format.
terraform_state is the identifier to the plan file used to create the latest state.
terraform_state_json is the identifier to the plan file used to create the latest state only in JSON format.
define an array of terraform variables files that belong to a different repository
list of terraform variables configured on the workspace.
Whether this workspace uses terragrunt to provision infrastructure
Terragrunt Version to use when provisioner is terragrunt.
Modified is the unix timestamp at which the resource was last modified in milliseconds.
{ "account": "x6", "associated_template": { "template_id": "7y", "version": "t" }, "backend_locked": true, "budget": 0.046163578, "cost_breakdown_json": "c4a2d99bc28d236098a095277b7eb0718d6be068", "cost_diff_json": "c4a2d99bc28d236098a095277b7eb0718d6be068", "cost_estimation_enabled": true, "created": 5881004612386662000, "default_pipelines": { "Est maiores quibusdam aliquid.": { … }, "Sint quos enim.": { … } }, "description": "this is a more detailed explanation of the resource.", "environment_variables": { "In ut nulla aut et vero.": { … }, "Pariatur maxime omnis qui.": { … } }, "identifier": "rrc", "modules_json": "c4a2d99bc28d236098a095277b7eb0718d6be068", "name": "resource name", "org": "yw4", "project": "r0", "provider_connector": "Sed eos voluptatibus.", "provider_connectors": [ { … }, { … }, { … } ], "providers_json": "c4a2d99bc28d236098a095277b7eb0718d6be068", "provisioner": "Adipisci voluptas nulla.", "provisioner_data": "Cupiditate modi ut aut ullam officia tenetur.", "provisioner_version": "Labore in dolores aut.", "prune_sensitive_data": true, "repository": "Perferendis quisquam culpa.", "repository_branch": "main", "repository_commit": "abc10ed", "repository_connector": "Repudiandae modi rerum aspernatur nihil.", "repository_path": "", "repository_sha": "abc10ed", "repository_submodules": "recursive", "run_all": false, "sparse_checkout": "Voluptas architecto eum voluptatum quia sit et.", "state_checksum": "d21c1662d8ce2c74f24efdc8db93eb34473b86810aeccca4b1518f70b0ccde8f", "status": "failed", "tags": { "foo": "bar" }, "terraform_plan_json": "f9e21473daaa2674d862b67a1339f4570e86de17", "terraform_state": "fc1200c7a7aa52109d762a9f005b149abef01479", "terraform_state_json": "c4a2d99bc28d236098a095277b7eb0718d6be068", "terraform_variable_files": [ { … }, { … } ], "terraform_variables": { "Ea deserunt adipisci et quod officiis.": { … }, "Repellat quia numquam nihil dolor sequi praesentium.": { … } }, "terragrunt_provider": false, "terragrunt_version": "Quidem quo necessitatibus ipsum optio voluptas fugit.", "updated": 6548318537415134000, "variable_sets": [ "Recusandae aut.", "Corporis non reiciendis.", "Sint sit aut quia beatae et qui.", "Enim ut sed omnis tempore sint est." ] }
define if cost estimation operations will be performed in this workspace
List of default pipelines associated with this workspace and any per-workspace overrides.
Description provides long-form text about the resource.
list of environment variables configured on the workspace.
Name is the human readable name for the resource.
Provider Connector is the reference to the connector for the infrastructure provider.
define an array of provider connectors that belong to Workspace
Provisioner defines the provisioning tool to use.
Provisioner Version defines the tool version to use.
prune_sensitive_data is a flag to enable or disable pruning of sensitive data
Repository is the name of the repository to use.
Repository Commit/Tag in which the code should be accessed.
Repository Connector is the reference to the connector to use for this code.
Repository Path is the path in which the infra code resides.
repository_submodules is the instruction about whether to clone submodules in the pipeline step
List of patterens that will be used for sparse checkout option of git clone
define an array of terraform variables files that belong to a different repository
list of terraform variables configured on the workspace.
Whether this workspace uses terragrunt to provision infrastructure
Terragrunt Version to use when provisioner is terragrunt.
- Mock server
https://apidocs.harness.io/_mock/openapi-merged/iacm/api/orgs/{org}/projects/{project}/workspaces/{identifier}
- Harness host URL
https://app.harness.io/iacm/api/orgs/{org}/projects/{project}/workspaces/{identifier}
- Vanity URL
https://app.harness.io/iacm/api/orgs/{org}/projects/{project}/workspaces/{identifier}
- curl
- JavaScript
- Node.js
- Python
- Java
- C#
- PHP
- Go
- Ruby
- R
- Payload
curl -i -X PUT \
https://apidocs.harness.io/_mock/openapi-merged/iacm/api/orgs/k0/projects/0/workspaces/h \
-H 'Content-Type: application/json' \
-H 'Harness-Account: 4y' \
-H 'x-api-key: YOUR_API_KEY_HERE' \
-d '{
"budget": 0.026462233,
"cost_estimation_enabled": true,
"default_pipelines": {
"Commodi pariatur non veritatis assumenda et mollitia.": {
"project_pipeline": "Libero et laudantium consequatur.",
"workspace_pipeline": "Est dolores non ad magni iure."
},
"Sapiente qui aut.": {
"project_pipeline": "Libero et laudantium consequatur.",
"workspace_pipeline": "Est dolores non ad magni iure."
}
},
"description": "this is a more detailed explanation of the resource.",
"environment_variables": {
"Aperiam quis qui.": {
"key": "01",
"value": "Ullam aspernatur qui sed iusto.",
"value_type": "string"
},
"Nam occaecati quas dicta.": {
"key": "01",
"value": "Ullam aspernatur qui sed iusto.",
"value_type": "string"
},
"Sint id sequi hic.": {
"key": "01",
"value": "Ullam aspernatur qui sed iusto.",
"value_type": "string"
}
},
"name": "resource name",
"provider_connector": "Cum rerum.",
"provider_connectors": [
{
"connector_ref": "jp",
"created": 1627590400,
"id": 8501884255817918000,
"terragrunt_provider": true,
"type": "gcp",
"updated": 1627686800,
"workspace_id": 5571489263414113000
},
{
"connector_ref": "jp",
"created": 1627590400,
"id": 8501884255817918000,
"terragrunt_provider": true,
"type": "gcp",
"updated": 1627686800,
"workspace_id": 5571489263414113000
},
{
"connector_ref": "jp",
"created": 1627590400,
"id": 8501884255817918000,
"terragrunt_provider": true,
"type": "gcp",
"updated": 1627686800,
"workspace_id": 5571489263414113000
}
],
"provisioner": "Odio vero ut velit sit.",
"provisioner_version": "Sed possimus adipisci.",
"prune_sensitive_data": true,
"repository": "Esse excepturi placeat doloribus aspernatur enim.",
"repository_branch": "main",
"repository_commit": "abc10ed",
"repository_connector": "Excepturi voluptas perspiciatis rerum.",
"repository_path": "",
"repository_sha": "abc10ed",
"repository_submodules": "recursive",
"run_all": false,
"sparse_checkout": "Accusantium non voluptatem.",
"tags": {
"foo": "bar"
},
"terraform_variable_files": [
{
"repository": "Occaecati a sint.",
"repository_branch": "main",
"repository_commit": "abc10ed",
"repository_connector": "Est deleniti culpa.",
"repository_path": "",
"repository_sha": "abc10ed"
},
{
"repository": "Occaecati a sint.",
"repository_branch": "main",
"repository_commit": "abc10ed",
"repository_connector": "Est deleniti culpa.",
"repository_path": "",
"repository_sha": "abc10ed"
},
{
"repository": "Occaecati a sint.",
"repository_branch": "main",
"repository_commit": "abc10ed",
"repository_connector": "Est deleniti culpa.",
"repository_path": "",
"repository_sha": "abc10ed"
}
],
"terraform_variables": {
"Eaque rerum facere praesentium cumque perferendis quia.": {
"key": "01",
"value": "Ullam aspernatur qui sed iusto.",
"value_type": "string"
},
"Sunt aliquid nam minus sunt modi.": {
"key": "01",
"value": "Ullam aspernatur qui sed iusto.",
"value_type": "string"
}
},
"terragrunt_provider": true,
"terragrunt_version": "Ex tenetur quisquam.",
"variable_sets": [
"Deleniti omnis sed maiores voluptatum.",
"Dolor eveniet aperiam aut architecto blanditiis."
]
}'
OK response.
The result of a single evaluation
{ "policy_evaluation": { "account_id": "XRQAjvT37acOiXx9PRaQMF", "action": "onrun", "created": 1636370209475, "details": [ … ], "entity": "7bbca5d4-e9f2-4955-9b2a-019ec4d3645e", "entity_metadata": "7bbca5d4-e9f2-4955-9b2a-019ec4d3645e", "id": 123, "input": "", "org_id": "test-org", "project_id": "test-project", "status": "error", "type": "pipeline,service" } }
- Mock server
https://apidocs.harness.io/_mock/openapi-merged/iacm/api/orgs/{org}/projects/{project}/workspaces/{identifier}/actions/force-unlock
- Harness host URL
https://app.harness.io/iacm/api/orgs/{org}/projects/{project}/workspaces/{identifier}/actions/force-unlock
- Vanity URL
https://app.harness.io/iacm/api/orgs/{org}/projects/{project}/workspaces/{identifier}/actions/force-unlock
- curl
- JavaScript
- Node.js
- Python
- Java
- C#
- PHP
- Go
- Ruby
- R
- Payload
curl -i -X POST \
https://apidocs.harness.io/_mock/openapi-merged/iacm/api/orgs/7m/projects/iqt/workspaces/bg1/actions/force-unlock \
-H 'Harness-Account: jl' \
-H 'x-api-key: YOUR_API_KEY_HERE'