Introduction
This article describes how to use the Endor Labs REST API. For a quickstart guide, see Quickstart for Endor Labs REST API. The Endor Labs command line toolendorctl is a convenient wrapper around the Endor Labs REST API and allows you to interact with Endor Labs without having to worry about the REST protocol details.
For more information, see Making a request below and the Endor Labs CLI documentation.
For a complete list of Endor Labs REST API endpoints, see the Endor Labs OpenAPI documentation.
About requests to the REST API
This section describes the elements that make up an API request: Every request to the REST API includes an HTTP method and a path. Depending on the REST API endpoint, you might also need to specify request headers, authentication information, list parameters, or body parameters. The REST API reference documentation describes the HTTP method, path, and parameters for every endpoint. It also displays example requests and responses for each endpoint. For more information, see the Endor Labs REST API documentation.HTTP method
The HTTP method of an endpoint defines the type of action it performs on a given resource. Some common HTTP methods are GET, POST, DELETE, and PATCH. The REST API reference documentation provides the HTTP method for every endpoint. For example, the HTTP method for the List Findings endpoint is GET. Where possible, the Endor Labs REST API strives to use an appropriate HTTP method for each action.Path
Each endpoint has a path. The Endor Labs REST API reference documentation gives the path for every endpoint. For example, the path for the List Findings endpoint ishttps://api.endorlabs.com/v1/namespaces/{tenant_meta.namespace}/findings and the path for the Get Finding endpoint is https://api.endorlabs.com/v1/namespaces/{tenant_meta.namespace}/findings/{uuid}.
The curly brackets in a path denote path parameters that you need to specify. Path parameters modify the endpoint path and are required in your request. For example, the path parameter for the List Findings endpoint is {tenant_meta.namespace}. To use this path in your API request, replace {tenant_meta.namespace} with the name of the namespace where you want to request a list of findings. To get a specific finding object, add the object UUID to the end of the path.
Headers
Headers provide extra information about the request and the desired response. Following are some examples of headers that you can use in your requests to the Endor Labs REST API. For an example of a request that uses headers, see Making a request.Authentication
All endpoints require authentication. Use theendorctl init command to authenticate with Endor Labs. For more information, see Authentication. For examples, see Making a request.
Accept-Encoding
You may optionally use theAccept-Encoding header to enable compression of HTTP responses for performance optimization. The following encodings are supported: gzip, br (Brotli), and zstd. If you specify multiple encodings, gzip takes priority. Ensure that the client can correctly handle the specified encoding. You can provide the Accept-Encoding header in the following format: Accept-Encoding: gzip, br, zstd.
Content-Type
To improve API performance, set theContent-Type header to application/jsoncompact. This prevents Endor Labs APIs from returning null or empty values, which is the default behavior.
Request-timeout
Use theRequest-timeout header to specify the amount of time, in seconds, that you are willing to wait for a server response. For example: --header "Request-Timeout: 10".
The corresponding option for endorctl requests is -t/--timeout, for example: -t 10s.
Parameters
Many API methods require or allow you to send additional information in parameters in your request. There are a few different types of parameters: Path parameters, list parameters, and body parameters.Path parameters
Path parameters modify the endpoint path. These parameters are required in your request. For more information, see Path.List parameters
List parameters allow you to control what data is returned for a request. These parameters are usually optional. The documentation for each Endor Labs REST API endpoint describes any list parameters that it supports. For example, all Endor Labs endpoints return one hundred objects by default. You can setpage_size=2 to return two objects instead of 100. You can set count=true to just return the number of objects. You can use the filter list parameter to only list objects that match a specified list of criteria (see filters). For examples of requests that use list parameters, see Making a request and Use cases.
Body parameters
Body parameters allow you to pass additional data to the API. These parameters can be optional or required, depending on the endpoint. The documentation for each Endor Labs REST API endpoint describes the body parameters that it supports. For more information, see the Endor Labs OpenAPI documentation. For example, the Create Policy endpoint requires that you specify a name, rule, query statement, and resource kinds for the new policy in your request. It also allows you to optionally specify other information, such as a description, actions, or tags to apply to the new policy. For an example of a request that uses body parameters, see Making a request.Making a request
The following example retrieves all findings for reachable functions. For more examples, see Use cases.- endorctl
- curl
- HTTP
- Setup
- Authenticate
endorctl init and your browser window will open automatically. Select your authentication provider from the available options and complete the authentication process.You can also specify your supported authentication provider manually.endorctl init --auth-mode google- Make a request
endorctl api list --resource Finding --filter "spec.finding_tags contains FINDING_TAGS_REACHABLE_FUNCTION"Note that you do not have to provide the access token or the namespace when using endorctl to access the Endor Labs REST API.