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/gitops/api/v1/agents/{agentIdentifier}/clusters/{identifier}
- Harness host URL
https://app.harness.io/gitops/api/v1/agents/{agentIdentifier}/clusters/{identifier}
- Vanity URL
https://app.harness.io/gitops/api/v1/agents/{agentIdentifier}/clusters/{identifier}
- curl
- JavaScript
- Node.js
- Python
- Java
- C#
- PHP
- Go
- Ruby
- R
- Payload
curl -i -X GET \
'https://apidocs.harness.io/_mock/openapi-merged/gitops/api/v1/agents/{agentIdentifier}/clusters/{identifier}?accountIdentifier=string&orgIdentifier=string&projectIdentifier=string&query.server=string&query.name=string&query.id.type=string&query.id.value=string&query.project=string' \
-H 'x-api-key: YOUR_API_KEY_HERE'
{ "accountIdentifier": "string", "orgIdentifier": "string", "projectIdentifier": "string", "agentIdentifier": "string", "identifier": "string", "cluster": { "server": "string", "name": "string", "config": { … }, "connectionState": { … }, "serverVersion": "string", "namespaces": [ … ], "refreshRequestedAt": { … }, "info": { … }, "shard_deprecated": "string", "clusterResources": true, "project": "string", "labels": { … }, "annotations": { … }, "type": "CUSTOMER_PROVIDED", "refreshRequestedAtTs": "2019-08-24T14:15:22Z", "shard": "string" }, "createdAt": "2019-08-24T14:15:22Z", "lastModifiedAt": "2019-08-24T14:15:22Z", "stale": true, "tags": { "property1": "string", "property2": "string" } }
- Mock server
https://apidocs.harness.io/_mock/openapi-merged/gitops/api/v1/agents/{agentIdentifier}/clusters/{identifier}
- Harness host URL
https://app.harness.io/gitops/api/v1/agents/{agentIdentifier}/clusters/{identifier}
- Vanity URL
https://app.harness.io/gitops/api/v1/agents/{agentIdentifier}/clusters/{identifier}
- curl
- JavaScript
- Node.js
- Python
- Java
- C#
- PHP
- Go
- Ruby
- R
- Payload
curl -i -X DELETE \
'https://apidocs.harness.io/_mock/openapi-merged/gitops/api/v1/agents/{agentIdentifier}/clusters/{identifier}?accountIdentifier=string&orgIdentifier=string&projectIdentifier=string&query.server=string&query.name=string&query.id.type=string&query.id.value=string&query.project=string&forceDelete=true' \
-H 'x-api-key: YOUR_API_KEY_HERE'
{}
paths: "f.a" paths: "f.b.d"
Here f
represents a field in some root message, a
and b
fields in the message found in f
, and d
a field found in the message in f.b
.
Field masks are used to specify a subset of fields that should be returned by a get operation or modified by an update operation. Field masks also have a custom JSON encoding (see below).
When used in the context of a projection, a response message or sub-message is filtered by the API to only contain those fields as specified in the mask. For example, if the mask in the previous example is applied to a response message as follows:
f { a : 22 b { d : 1 x : 2 } y : 13 } z: 8
The result will not contain specific values for fields x,y and z (their value will be set to the default, and omitted in proto text output):
f { a : 22 b { d : 1 } }
A repeated field is not allowed except at the last position of a paths string.
If a FieldMask object is not present in a get operation, the operation applies to all fields (as if a FieldMask of all fields had been specified).
Note that a field mask does not necessarily apply to the top-level response message. In case of a REST get operation, the field mask applies directly to the response, but in case of a REST list operation, the mask instead applies to each individual message in the returned resource list. In case of a REST custom method, other definitions may be used. Where the mask applies will be clearly documented together with its declaration in the API. In any case, the effect on the returned resource/resources is required behavior for APIs.
A field mask in update operations specifies which fields of the targeted resource are going to be updated. The API is required to only change the values of the fields as specified in the mask and leave the others untouched. If a resource is passed in to describe the updated values, the API ignores the values of all fields not covered by the mask.
If a repeated field is specified for an update operation, new values will be appended to the existing repeated field in the target resource. Note that a repeated field is only allowed in the last position of a paths
string.
If a sub-message is specified in the last position of the field mask for an update operation, then new value will be merged into the existing sub-message in the target resource.
For example, given the target message:
f { b { d: 1 x: 2 } c: [1] }
And an update message:
f { b { d: 10 } c: [2] }
then if the field mask is:
paths: ["f.b", "f.c"]
then the result will be:
f { b { d: 10 x: 2 } c: [1, 2] }
An implementation may provide options to override this default behavior for repeated and message fields.
In order to reset a field's value to the default, the field must be in the mask and set to the default value in the provided resource. Hence, in order to reset all fields of a resource, provide a default instance of the resource and set all fields in the mask, or do not provide a mask as described below.
If a field mask is not present on update, the operation applies to all fields (as if a field mask of all fields has been specified). Note that in the presence of schema evolution, this may mean that fields the client does not know and has therefore not filled into the request will be reset to their default. If this is unwanted behavior, a specific service may require a client to always specify a field mask, producing an error if not.
As with get operations, the location of the resource which describes the updated values in the request message depends on the operation kind. In any case, the effect of the field mask is required to be honored by the API.
The HTTP kind of an update operation which uses a field mask must be set to PATCH instead of PUT in order to satisfy HTTP semantics (PUT must only be used for full updates).
In JSON, a field mask is encoded as a single string where paths are separated by a comma. Fields name in each path are converted to/from lower-camel naming conventions.
As an example, consider the following message declarations:
message Profile { User user = 1; Photo photo = 2; } message User { string display_name = 1; string address = 2; }
In proto a field mask for Profile
may look as such:
mask { paths: "user.display_name" paths: "photo" }
In JSON, the same mask is represented as below:
{ mask: "user.displayName,photo" }
Field masks treat fields in oneofs just as regular fields. Consider the following message:
message SampleMessage { oneof test_oneof { string name = 4; SubMessage sub_message = 9; } }
The field mask can be:
mask { paths: "name" }
Or:
mask { paths: "sub_message" }
Note that oneof type names ("test_oneof" in this case) cannot be used in paths.
The implementation of any API method which has a FieldMask type field in the request should verify the included field paths, and return an INVALID_ARGUMENT
error if any path is unmappable.
- Mock server
https://apidocs.harness.io/_mock/openapi-merged/gitops/api/v1/agents/{agentIdentifier}/clusters/{identifier}
- Harness host URL
https://app.harness.io/gitops/api/v1/agents/{agentIdentifier}/clusters/{identifier}
- Vanity URL
https://app.harness.io/gitops/api/v1/agents/{agentIdentifier}/clusters/{identifier}
- curl
- JavaScript
- Node.js
- Python
- Java
- C#
- PHP
- Go
- Ruby
- R
- Payload
curl -i -X PUT \
'https://apidocs.harness.io/_mock/openapi-merged/gitops/api/v1/agents/{agentIdentifier}/clusters/{identifier}?accountIdentifier=string&orgIdentifier=string&projectIdentifier=string' \
-H 'Content-Type: application/json' \
-H 'x-api-key: YOUR_API_KEY_HERE' \
-d '{
"cluster": {
"server": "string",
"name": "string",
"config": {
"username": "string",
"password": "string",
"bearerToken": "string",
"tlsClientConfig": {
"insecure": true,
"serverName": "string",
"certData": "string",
"keyData": "string",
"caData": "string"
},
"awsAuthConfig": {
"clusterName": "string",
"roleARN": "string"
},
"execProviderConfig": {
"command": "string",
"args": [
"string"
],
"env": {
"property1": "string",
"property2": "string"
},
"apiVersion": "string",
"installHint": "string"
},
"clusterConnectionType": "string",
"roleARN": "string",
"awsClusterName": "string",
"disableCompression": true,
"proxyUrl": "string"
},
"connectionState": {
"status": "string",
"message": "string",
"attemptedAt": {
"seconds": "string",
"nanos": 0
},
"attemptedAtTs": "2019-08-24T14:15:22Z"
},
"serverVersion": "string",
"namespaces": [
"string"
],
"refreshRequestedAt": {
"seconds": "string",
"nanos": 0
},
"info": {
"connectionState": {
"status": "string",
"message": "string",
"attemptedAt": {
"seconds": "string",
"nanos": 0
},
"attemptedAtTs": "2019-08-24T14:15:22Z"
},
"serverVersion": "string",
"cacheInfo": {
"resourcesCount": "string",
"apisCount": "string",
"lastCacheSyncTime": {
"seconds": "string",
"nanos": 0
},
"lastCacheSyncTimeTs": "2019-08-24T14:15:22Z"
},
"applicationsCount": "string",
"apiVersions": [
"string"
]
},
"shard_deprecated": "string",
"clusterResources": true,
"project": "string",
"labels": {
"property1": "string",
"property2": "string"
},
"annotations": {
"property1": "string",
"property2": "string"
},
"type": "CUSTOMER_PROVIDED",
"refreshRequestedAtTs": "2019-08-24T14:15:22Z",
"shard": "string"
},
"updatedFields": [
"string"
],
"updateMask": {
"paths": [
"string"
]
},
"tags": {
"property1": "string",
"property2": "string"
},
"id": {
"type": "string",
"value": "string"
}
}'
{ "accountIdentifier": "string", "orgIdentifier": "string", "projectIdentifier": "string", "agentIdentifier": "string", "identifier": "string", "cluster": { "server": "string", "name": "string", "config": { … }, "connectionState": { … }, "serverVersion": "string", "namespaces": [ … ], "refreshRequestedAt": { … }, "info": { … }, "shard_deprecated": "string", "clusterResources": true, "project": "string", "labels": { … }, "annotations": { … }, "type": "CUSTOMER_PROVIDED", "refreshRequestedAtTs": "2019-08-24T14:15:22Z", "shard": "string" }, "createdAt": "2019-08-24T14:15:22Z", "lastModifiedAt": "2019-08-24T14:15:22Z", "stale": true, "tags": { "property1": "string", "property2": "string" } }