# Datasets

## List datasets

> Retrieves a list of datasets

```json
{"openapi":"3.0.0","info":{"title":"Lenses API","version":"6.1"},"tags":[{"name":"agent_Datasets"}],"servers":[{"url":"{server}","variables":{"server":{"default":"https://api.example.com"}}}],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","description":"The bearer token can be obtained by creating a ServiceAccount.\n"},"cookieAuth":{"type":"apiKey","in":"cookie","name":"session_id","description":"On successful SAML/SSO login, the API will set a cookie with a session id.\n"}},"schemas":{"agent_DatasetField":{"type":"string","enum":["name","records","connectionName","sourceType","isSystemEntity","recordsPerSecond","keyType","valueType","replication","consumers","partitions","retentionBytes","retentionMs","sizeBytes","version","format","compatibility","backupRestoreState"]},"agent_Order":{"type":"string","enum":["asc","desc"]},"agent_Results":{"required":["datasets"],"type":"object","properties":{"datasets":{"$ref":"#/components/schemas/agent_Page_DatasetMatchWithLrn"},"sourceTypes":{"type":"array","items":{"$ref":"#/components/schemas/agent_SourceType"}}}},"agent_Page_DatasetMatchWithLrn":{"required":["pagesAmount","totalCount"],"type":"object","properties":{"values":{"type":"array","items":{"$ref":"#/components/schemas/agent_DatasetMatchWithLrn"}},"pagesAmount":{"type":"integer","format":"int64"},"totalCount":{"type":"integer","format":"int64"}}},"agent_DatasetMatchWithLrn":{"oneOf":[{"$ref":"#/components/schemas/agent_Kafka"},{"$ref":"#/components/schemas/agent_SchemaRegistrySubject"}],"discriminator":{"propertyName":"sourceType","mapping":{"Kafka":"#/components/schemas/agent_Kafka","SchemaRegistrySubject":"#/components/schemas/agent_SchemaRegistrySubject"}}},"agent_Kafka":{"required":["name","recordsPerSecond","keyType","valueType","connectionName","replication","consumers","partitions","isSystemEntity","isMarkedForDeletion","isCompacted","permissions","lrn","sourceType"],"type":"object","properties":{"name":{"type":"string"},"highlights":{"type":"array","items":{"$ref":"#/components/schemas/agent_Highlight"}},"records":{"type":"integer","format":"int64"},"recordsPerSecond":{"type":"integer","format":"int64"},"keyType":{"type":"string"},"valueType":{"type":"string"},"connectionName":{"type":"string"},"replication":{"type":"integer"},"consumers":{"type":"integer"},"partitions":{"type":"integer"},"fields":{"$ref":"#/components/schemas/agent_Fields"},"isSystemEntity":{"type":"boolean"},"isMarkedForDeletion":{"type":"boolean"},"isCompacted":{"type":"boolean"},"sizeBytes":{"type":"integer","format":"int64"},"policies":{"type":"array","items":{"$ref":"#/components/schemas/agent_PolicyMatchDetailsWithLrn"}},"permissions":{"type":"array","items":{"type":"string"},"minItems":1},"description":{"type":"string"},"tags":{"type":"array","items":{"$ref":"#/components/schemas/agent_DatasetTag"}},"retentionMs":{"type":"integer","format":"int64"},"retentionBytes":{"type":"integer","format":"int64"},"backupRestoreState":{"$ref":"#/components/schemas/agent_BackupRestoreState"},"lrn":{"type":"string"},"sourceType":{"type":"string"}}},"agent_Highlight":{"required":["fieldName","startIndex","endIndex","arrayIndex"],"type":"object","properties":{"fieldName":{"type":"string"},"startIndex":{"type":"integer"},"endIndex":{"type":"integer"},"arrayIndex":{"type":"integer"}}},"agent_Fields":{"type":"object","properties":{"key":{"type":"array","items":{"$ref":"#/components/schemas/agent_Field"}},"value":{"type":"array","items":{"$ref":"#/components/schemas/agent_Field"}}}},"agent_Field":{"required":["name","typeDetails","isNullable"],"type":"object","properties":{"name":{"type":"string"},"typeDetails":{"$ref":"#/components/schemas/agent_FieldTypeDetails"},"description":{"type":"string"},"ancestors":{"type":"array","items":{"type":"string"}},"highlights":{"type":"array","items":{"$ref":"#/components/schemas/agent_Highlight"}},"isNullable":{"type":"boolean"},"default":{"type":"string"}}},"agent_FieldTypeDetails":{"oneOf":[{"$ref":"#/components/schemas/agent_Lenses"},{"$ref":"#/components/schemas/agent_Native"}]},"agent_Lenses":{"required":["lensesDataType"],"type":"object","properties":{"lensesDataType":{"type":"string"}}},"agent_Native":{"required":["native","lensesDataType"],"type":"object","properties":{"native":{"type":"string"},"lensesDataType":{"type":"string"}}},"agent_PolicyMatchDetailsWithLrn":{"required":["policyId","policyName","policyCategory","obfuscation","lrn"],"type":"object","properties":{"policyId":{"type":"string"},"policyName":{"type":"string"},"policyCategory":{"type":"string"},"obfuscation":{"type":"string"},"matchingKeyFields":{"type":"array","items":{"$ref":"#/components/schemas/agent_PolicyFieldMatch"}},"matchingValueFields":{"type":"array","items":{"$ref":"#/components/schemas/agent_PolicyFieldMatch"}},"lrn":{"type":"string"}}},"agent_PolicyFieldMatch":{"required":["name"],"type":"object","properties":{"name":{"type":"string"},"parents":{"type":"array","items":{"type":"string"}}}},"agent_DatasetTag":{"required":["name"],"type":"object","properties":{"name":{"type":"string"}}},"agent_BackupRestoreState":{"oneOf":[{"$ref":"#/components/schemas/agent_Backup"},{"$ref":"#/components/schemas/agent_BackupRestore"},{"$ref":"#/components/schemas/agent_Restore"}]},"agent_Backup":{"type":"object"},"agent_BackupRestore":{"type":"object"},"agent_Restore":{"type":"object"},"agent_SchemaRegistrySubject":{"required":["name","connectionName","isSystemEntity","permissions","format","version","schemaId","lrn","sourceType"],"type":"object","properties":{"name":{"type":"string"},"highlights":{"type":"array","items":{"$ref":"#/components/schemas/agent_Highlight"}},"sizeBytes":{"type":"integer","format":"int64"},"records":{"type":"integer","format":"int64"},"connectionName":{"type":"string"},"fields":{"$ref":"#/components/schemas/agent_Fields"},"isSystemEntity":{"type":"boolean"},"policies":{"type":"array","items":{"$ref":"#/components/schemas/agent_PolicyMatchDetailsWithLrn"}},"permissions":{"type":"array","items":{"type":"string"},"minItems":1},"description":{"type":"string"},"tags":{"type":"array","items":{"$ref":"#/components/schemas/agent_DatasetTag"}},"format":{"type":"string"},"version":{"type":"integer"},"schema":{"type":"string"},"schemaId":{"type":"string"},"references":{"type":"array","items":{"$ref":"#/components/schemas/agent_SchemaReference"}},"compatibility":{"type":"string"},"versions":{"type":"array","items":{"$ref":"#/components/schemas/agent_SchemaVersion"},"minItems":1},"lrn":{"type":"string"},"sourceType":{"type":"string"}}},"agent_SchemaReference":{"required":["subjectName","schemaName","version"],"type":"object","properties":{"subjectName":{"type":"string"},"schemaName":{"type":"string"},"version":{"type":"integer"}}},"agent_SchemaVersion":{"required":["id","version","schema","format"],"type":"object","properties":{"id":{"type":"string"},"version":{"type":"integer"},"schema":{"type":"string"},"format":{"type":"string"},"references":{"type":"array","items":{"$ref":"#/components/schemas/agent_SchemaReference"}}}},"agent_SourceType":{"type":"string","enum":["Kafka","SchemaRegistrySubject"]},"agent_BadRequest":{"required":["error"],"type":"object","properties":{"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"error":{"type":"string"},"errorType":{"type":"string"}}},"agent_FieldError":{"required":["field","error"],"type":"object","properties":{"field":{"type":"string"},"error":{"type":"string"},"lineNumber":{"type":"integer"},"columnNumber":{"type":"integer"}}},"agent_Unauthorized":{"required":["error"],"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"errorType":{"type":"string"}}},"agent_LicenseError":{"required":["error"],"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"errorType":{"type":"string"}}},"agent_Forbidden":{"required":["error"],"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"errorType":{"type":"string"}}},"agent_NotFound":{"required":["error"],"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"errorType":{"type":"string"}}},"agent_InternalError":{"required":["error"],"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"errorType":{"type":"string"}}}}},"paths":{"/api/v1/environments/{environment}/proxy/api/v1/datasets":{"get":{"tags":["agent_Datasets"],"summary":"List datasets","description":"Retrieves a list of datasets","operationId":"listDatasets","parameters":[{"name":"environment","in":"path","required":true,"schema":{"type":"string"}},{"name":"page","in":"query","description":"The page number to be returned, must be greater than zero. Defaults to 1.","required":false,"schema":{"type":"integer"}},{"name":"pageSize","in":"query","description":"The elements amount on a single page, must be greater than zero.","required":true,"schema":{"type":"integer"}},{"name":"query","in":"query","description":"A search keyword to match dataset, fields and description against.","required":false,"schema":{"type":"string"}},{"name":"connections","in":"query","description":"A list of connection names to filter by. All connections will be included when no value is supplied.","required":false,"schema":{"type":"array","items":{"type":"string"}}},{"name":"tags","in":"query","description":"A list of tag names to filter by. All tags will be included when no value is supplied.","required":false,"schema":{"type":"array","items":{"type":"string"}}},{"name":"sortBy","in":"query","description":"The field to sort results by","required":false,"schema":{"$ref":"#/components/schemas/agent_DatasetField"}},{"name":"sortingOrder","in":"query","description":"Sorting order. Defaults to ascending","required":false,"schema":{"$ref":"#/components/schemas/agent_Order"}},{"name":"includeSystemEntities","in":"query","description":"A flag to include in the search also system entities (e.g. Kafka's `__consumer_offsets` topic).","required":false,"schema":{"type":"boolean"}},{"name":"includeMetadata","in":"query","description":"Whether to search only by table name, or also to include field names/documentation (defaults to true)","required":false,"schema":{"type":"boolean"}},{"name":"format","in":"query","description":"Schema format. Relevant only when sourceType is `SchemaRegistrySubject`","required":false,"schema":{"type":"array","items":{"type":"string"}}},{"name":"hasRecords","in":"query","description":"Filter based on whether the dataset has records","required":false,"schema":{"type":"boolean"}},{"name":"compacted","in":"query","description":"Filter based on compacted. Relevant only when sourceType is `Kafka`","required":false,"schema":{"type":"boolean"}}],"responses":{"200":{"description":"A response wrapping a paginated list of datasets and the set of relative source types","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_Results"}}}},"400":{"description":"The request input was invalid","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_BadRequest"}}}},"401":{"description":"Authentication error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_Unauthorized"}}}},"402":{"description":"The purchased Lenses license does not provide access to this feature","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_LicenseError"}}}},"403":{"description":"Authorisation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_Forbidden"}}}},"404":{"description":"The requested resource cannot be found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_NotFound"}}}},"500":{"description":"An internal server error has occurred","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_InternalError"}}}}}}}}}
```

## Bulk delete datasets

> Deletes multiple datasets at once

```json
{"openapi":"3.0.0","info":{"title":"Lenses API","version":"6.1"},"tags":[{"name":"agent_Datasets"}],"servers":[{"url":"{server}","variables":{"server":{"default":"https://api.example.com"}}}],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","description":"The bearer token can be obtained by creating a ServiceAccount.\n"},"cookieAuth":{"type":"apiKey","in":"cookie","name":"session_id","description":"On successful SAML/SSO login, the API will set a cookie with a session id.\n"}},"schemas":{"agent_BulkDeleteRequest":{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/agent_BulkDeleteRequestItem"}}}},"agent_BulkDeleteRequestItem":{"required":["id"],"type":"object","properties":{"id":{"type":"string"}}},"agent_BulkDeleteResult":{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/agent_BulkDeleteResultItem"}}}},"agent_BulkDeleteResultItem":{"required":["id","success"],"type":"object","properties":{"id":{"type":"string"},"success":{"type":"boolean"},"message":{"type":"string"}}},"agent_BadRequest":{"required":["error"],"type":"object","properties":{"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"error":{"type":"string"},"errorType":{"type":"string"}}},"agent_FieldError":{"required":["field","error"],"type":"object","properties":{"field":{"type":"string"},"error":{"type":"string"},"lineNumber":{"type":"integer"},"columnNumber":{"type":"integer"}}},"agent_Unauthorized":{"required":["error"],"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"errorType":{"type":"string"}}},"agent_LicenseError":{"required":["error"],"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"errorType":{"type":"string"}}},"agent_Forbidden":{"required":["error"],"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"errorType":{"type":"string"}}},"agent_NotFound":{"required":["error"],"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"errorType":{"type":"string"}}},"agent_InternalError":{"required":["error"],"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"errorType":{"type":"string"}}}}},"paths":{"/api/v1/environments/{environment}/proxy/api/v1/bulk/datasets/delete":{"post":{"tags":["agent_Datasets"],"summary":"Bulk delete datasets","description":"Deletes multiple datasets at once","operationId":"bulkDeleteDatasets","parameters":[{"name":"environment","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"description":"The request body contains a list of datasets to delete. The dataset name should be prefixed with the connection alias name, for example: alias://datasetname","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_BulkDeleteRequest"}}},"required":true},"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_BulkDeleteResult"}}}},"400":{"description":"The request input was invalid","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_BadRequest"}}}},"401":{"description":"Authentication error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_Unauthorized"}}}},"402":{"description":"The purchased Lenses license does not provide access to this feature","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_LicenseError"}}}},"403":{"description":"Authorisation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_Forbidden"}}}},"404":{"description":"The requested resource cannot be found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_NotFound"}}}},"500":{"description":"An internal server error has occurred","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_InternalError"}}}}}}}}}
```

## Set dataset description

> Sets a dataset description. Will respond with a bad request if a blank description is supplied

```json
{"openapi":"3.0.0","info":{"title":"Lenses API","version":"6.1"},"tags":[{"name":"agent_Datasets"}],"servers":[{"url":"{server}","variables":{"server":{"default":"https://api.example.com"}}}],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","description":"The bearer token can be obtained by creating a ServiceAccount.\n"},"cookieAuth":{"type":"apiKey","in":"cookie","name":"session_id","description":"On successful SAML/SSO login, the API will set a cookie with a session id.\n"}},"schemas":{"agent_SetDescription":{"type":"object","properties":{"description":{"type":"string"}}},"agent_BadRequest":{"required":["error"],"type":"object","properties":{"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"error":{"type":"string"},"errorType":{"type":"string"}}},"agent_FieldError":{"required":["field","error"],"type":"object","properties":{"field":{"type":"string"},"error":{"type":"string"},"lineNumber":{"type":"integer"},"columnNumber":{"type":"integer"}}},"agent_Unauthorized":{"required":["error"],"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"errorType":{"type":"string"}}},"agent_LicenseError":{"required":["error"],"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"errorType":{"type":"string"}}},"agent_Forbidden":{"required":["error"],"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"errorType":{"type":"string"}}},"agent_NotFound":{"required":["error"],"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"errorType":{"type":"string"}}},"agent_InternalError":{"required":["error"],"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"errorType":{"type":"string"}}}}},"paths":{"/api/v1/environments/{environment}/proxy/api/v1/datasets/{connection}/{datasetName}/description":{"put":{"tags":["agent_Datasets"],"summary":"Set dataset description","description":"Sets a dataset description. Will respond with a bad request if a blank description is supplied","operationId":"setDatasetDescription","parameters":[{"name":"environment","in":"path","required":true,"schema":{"type":"string"}},{"name":"connection","in":"path","required":true,"schema":{"type":"string"}},{"name":"datasetName","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"description":"A non-blank dataset description","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_SetDescription"}}},"required":true},"responses":{"200":{"description":""},"400":{"description":"The request input was invalid","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_BadRequest"}}}},"401":{"description":"Authentication error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_Unauthorized"}}}},"402":{"description":"The purchased Lenses license does not provide access to this feature","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_LicenseError"}}}},"403":{"description":"Authorisation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_Forbidden"}}}},"404":{"description":"The requested resource cannot be found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_NotFound"}}}},"500":{"description":"An internal server error has occurred","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_InternalError"}}}}}}}}}
```

## Set dataset tags

> Add one or more tags to a dataset

```json
{"openapi":"3.0.0","info":{"title":"Lenses API","version":"6.1"},"tags":[{"name":"agent_Datasets"}],"servers":[{"url":"{server}","variables":{"server":{"default":"https://api.example.com"}}}],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","description":"The bearer token can be obtained by creating a ServiceAccount.\n"},"cookieAuth":{"type":"apiKey","in":"cookie","name":"session_id","description":"On successful SAML/SSO login, the API will set a cookie with a session id.\n"}},"schemas":{"agent_SetTags":{"type":"object","properties":{"tags":{"type":"array","items":{"$ref":"#/components/schemas/agent_DatasetTag1"}}}},"agent_DatasetTag1":{"required":["name"],"type":"object","properties":{"name":{"type":"string"}}},"agent_BadRequest":{"required":["error"],"type":"object","properties":{"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"error":{"type":"string"},"errorType":{"type":"string"}}},"agent_FieldError":{"required":["field","error"],"type":"object","properties":{"field":{"type":"string"},"error":{"type":"string"},"lineNumber":{"type":"integer"},"columnNumber":{"type":"integer"}}},"agent_Unauthorized":{"required":["error"],"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"errorType":{"type":"string"}}},"agent_LicenseError":{"required":["error"],"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"errorType":{"type":"string"}}},"agent_Forbidden":{"required":["error"],"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"errorType":{"type":"string"}}},"agent_NotFound":{"required":["error"],"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"errorType":{"type":"string"}}},"agent_InternalError":{"required":["error"],"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"errorType":{"type":"string"}}}}},"paths":{"/api/v1/environments/{environment}/proxy/api/v1/datasets/{connection}/{datasetName}/tags":{"put":{"tags":["agent_Datasets"],"summary":"Set dataset tags","description":"Add one or more tags to a dataset","operationId":"setDatasetTags","parameters":[{"name":"environment","in":"path","required":true,"schema":{"type":"string"}},{"name":"connection","in":"path","required":true,"schema":{"type":"string"}},{"name":"datasetName","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"description":"The list of tags to be set","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_SetTags"}}},"required":true},"responses":{"200":{"description":""},"400":{"description":"The request input was invalid","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_BadRequest"}}}},"401":{"description":"Authentication error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_Unauthorized"}}}},"402":{"description":"The purchased Lenses license does not provide access to this feature","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_LicenseError"}}}},"403":{"description":"Authorisation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_Forbidden"}}}},"404":{"description":"The requested resource cannot be found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_NotFound"}}}},"500":{"description":"An internal server error has occurred","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_InternalError"}}}}}}}}}
```

## Get dataset details

> Get a single dataset by connection/name. While information mastered externally might be \
> &#x20;a few second out of sync with their respective sources (e.g. JMX metadata, etc), information mastered in Lenses's db is guaranteed to be up to date (e.g. \
> tags, descriptions).

```json
{"openapi":"3.0.0","info":{"title":"Lenses API","version":"6.1"},"tags":[{"name":"agent_Datasets"}],"servers":[{"url":"{server}","variables":{"server":{"default":"https://api.example.com"}}}],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","description":"The bearer token can be obtained by creating a ServiceAccount.\n"},"cookieAuth":{"type":"apiKey","in":"cookie","name":"session_id","description":"On successful SAML/SSO login, the API will set a cookie with a session id.\n"}},"schemas":{"agent_DatasetMatchWithLrn":{"oneOf":[{"$ref":"#/components/schemas/agent_Kafka"},{"$ref":"#/components/schemas/agent_SchemaRegistrySubject"}],"discriminator":{"propertyName":"sourceType","mapping":{"Kafka":"#/components/schemas/agent_Kafka","SchemaRegistrySubject":"#/components/schemas/agent_SchemaRegistrySubject"}}},"agent_Kafka":{"required":["name","recordsPerSecond","keyType","valueType","connectionName","replication","consumers","partitions","isSystemEntity","isMarkedForDeletion","isCompacted","permissions","lrn","sourceType"],"type":"object","properties":{"name":{"type":"string"},"highlights":{"type":"array","items":{"$ref":"#/components/schemas/agent_Highlight"}},"records":{"type":"integer","format":"int64"},"recordsPerSecond":{"type":"integer","format":"int64"},"keyType":{"type":"string"},"valueType":{"type":"string"},"connectionName":{"type":"string"},"replication":{"type":"integer"},"consumers":{"type":"integer"},"partitions":{"type":"integer"},"fields":{"$ref":"#/components/schemas/agent_Fields"},"isSystemEntity":{"type":"boolean"},"isMarkedForDeletion":{"type":"boolean"},"isCompacted":{"type":"boolean"},"sizeBytes":{"type":"integer","format":"int64"},"policies":{"type":"array","items":{"$ref":"#/components/schemas/agent_PolicyMatchDetailsWithLrn"}},"permissions":{"type":"array","items":{"type":"string"},"minItems":1},"description":{"type":"string"},"tags":{"type":"array","items":{"$ref":"#/components/schemas/agent_DatasetTag"}},"retentionMs":{"type":"integer","format":"int64"},"retentionBytes":{"type":"integer","format":"int64"},"backupRestoreState":{"$ref":"#/components/schemas/agent_BackupRestoreState"},"lrn":{"type":"string"},"sourceType":{"type":"string"}}},"agent_Highlight":{"required":["fieldName","startIndex","endIndex","arrayIndex"],"type":"object","properties":{"fieldName":{"type":"string"},"startIndex":{"type":"integer"},"endIndex":{"type":"integer"},"arrayIndex":{"type":"integer"}}},"agent_Fields":{"type":"object","properties":{"key":{"type":"array","items":{"$ref":"#/components/schemas/agent_Field"}},"value":{"type":"array","items":{"$ref":"#/components/schemas/agent_Field"}}}},"agent_Field":{"required":["name","typeDetails","isNullable"],"type":"object","properties":{"name":{"type":"string"},"typeDetails":{"$ref":"#/components/schemas/agent_FieldTypeDetails"},"description":{"type":"string"},"ancestors":{"type":"array","items":{"type":"string"}},"highlights":{"type":"array","items":{"$ref":"#/components/schemas/agent_Highlight"}},"isNullable":{"type":"boolean"},"default":{"type":"string"}}},"agent_FieldTypeDetails":{"oneOf":[{"$ref":"#/components/schemas/agent_Lenses"},{"$ref":"#/components/schemas/agent_Native"}]},"agent_Lenses":{"required":["lensesDataType"],"type":"object","properties":{"lensesDataType":{"type":"string"}}},"agent_Native":{"required":["native","lensesDataType"],"type":"object","properties":{"native":{"type":"string"},"lensesDataType":{"type":"string"}}},"agent_PolicyMatchDetailsWithLrn":{"required":["policyId","policyName","policyCategory","obfuscation","lrn"],"type":"object","properties":{"policyId":{"type":"string"},"policyName":{"type":"string"},"policyCategory":{"type":"string"},"obfuscation":{"type":"string"},"matchingKeyFields":{"type":"array","items":{"$ref":"#/components/schemas/agent_PolicyFieldMatch"}},"matchingValueFields":{"type":"array","items":{"$ref":"#/components/schemas/agent_PolicyFieldMatch"}},"lrn":{"type":"string"}}},"agent_PolicyFieldMatch":{"required":["name"],"type":"object","properties":{"name":{"type":"string"},"parents":{"type":"array","items":{"type":"string"}}}},"agent_DatasetTag":{"required":["name"],"type":"object","properties":{"name":{"type":"string"}}},"agent_BackupRestoreState":{"oneOf":[{"$ref":"#/components/schemas/agent_Backup"},{"$ref":"#/components/schemas/agent_BackupRestore"},{"$ref":"#/components/schemas/agent_Restore"}]},"agent_Backup":{"type":"object"},"agent_BackupRestore":{"type":"object"},"agent_Restore":{"type":"object"},"agent_SchemaRegistrySubject":{"required":["name","connectionName","isSystemEntity","permissions","format","version","schemaId","lrn","sourceType"],"type":"object","properties":{"name":{"type":"string"},"highlights":{"type":"array","items":{"$ref":"#/components/schemas/agent_Highlight"}},"sizeBytes":{"type":"integer","format":"int64"},"records":{"type":"integer","format":"int64"},"connectionName":{"type":"string"},"fields":{"$ref":"#/components/schemas/agent_Fields"},"isSystemEntity":{"type":"boolean"},"policies":{"type":"array","items":{"$ref":"#/components/schemas/agent_PolicyMatchDetailsWithLrn"}},"permissions":{"type":"array","items":{"type":"string"},"minItems":1},"description":{"type":"string"},"tags":{"type":"array","items":{"$ref":"#/components/schemas/agent_DatasetTag"}},"format":{"type":"string"},"version":{"type":"integer"},"schema":{"type":"string"},"schemaId":{"type":"string"},"references":{"type":"array","items":{"$ref":"#/components/schemas/agent_SchemaReference"}},"compatibility":{"type":"string"},"versions":{"type":"array","items":{"$ref":"#/components/schemas/agent_SchemaVersion"},"minItems":1},"lrn":{"type":"string"},"sourceType":{"type":"string"}}},"agent_SchemaReference":{"required":["subjectName","schemaName","version"],"type":"object","properties":{"subjectName":{"type":"string"},"schemaName":{"type":"string"},"version":{"type":"integer"}}},"agent_SchemaVersion":{"required":["id","version","schema","format"],"type":"object","properties":{"id":{"type":"string"},"version":{"type":"integer"},"schema":{"type":"string"},"format":{"type":"string"},"references":{"type":"array","items":{"$ref":"#/components/schemas/agent_SchemaReference"}}}},"agent_BadRequest":{"required":["error"],"type":"object","properties":{"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"error":{"type":"string"},"errorType":{"type":"string"}}},"agent_FieldError":{"required":["field","error"],"type":"object","properties":{"field":{"type":"string"},"error":{"type":"string"},"lineNumber":{"type":"integer"},"columnNumber":{"type":"integer"}}},"agent_Unauthorized":{"required":["error"],"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"errorType":{"type":"string"}}},"agent_LicenseError":{"required":["error"],"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"errorType":{"type":"string"}}},"agent_Forbidden":{"required":["error"],"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"errorType":{"type":"string"}}},"agent_NotFound":{"required":["error"],"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"errorType":{"type":"string"}}},"agent_InternalError":{"required":["error"],"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"errorType":{"type":"string"}}}}},"paths":{"/api/v1/environments/{environment}/proxy/api/v1/datasets/{connection}/{dataset}":{"get":{"tags":["agent_Datasets"],"summary":"Get dataset details","description":"Get a single dataset by connection/name. While information mastered externally might be \n a few second out of sync with their respective sources (e.g. JMX metadata, etc), information mastered in Lenses's db is guaranteed to be up to date (e.g. \ntags, descriptions).","operationId":"getDataset","parameters":[{"name":"environment","in":"path","required":true,"schema":{"type":"string"}},{"name":"connection","in":"path","required":true,"schema":{"type":"string"}},{"name":"dataset","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_DatasetMatchWithLrn"}}}},"400":{"description":"The request input was invalid","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_BadRequest"}}}},"401":{"description":"Authentication error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_Unauthorized"}}}},"402":{"description":"The purchased Lenses license does not provide access to this feature","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_LicenseError"}}}},"403":{"description":"Authorisation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_Forbidden"}}}},"404":{"description":"The requested resource cannot be found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_NotFound"}}}},"500":{"description":"An internal server error has occurred","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_InternalError"}}}}}}}}}
```

## Get dataset tags

> Get tags sorted by dataset count

```json
{"openapi":"3.0.0","info":{"title":"Lenses API","version":"6.1"},"tags":[{"name":"agent_Datasets"}],"servers":[{"url":"{server}","variables":{"server":{"default":"https://api.example.com"}}}],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","description":"The bearer token can be obtained by creating a ServiceAccount.\n"},"cookieAuth":{"type":"apiKey","in":"cookie","name":"session_id","description":"On successful SAML/SSO login, the API will set a cookie with a session id.\n"}},"schemas":{"agent_TagCounts":{"type":"object","properties":{"tags":{"type":"array","items":{"$ref":"#/components/schemas/agent_TagCount"}}}},"agent_TagCount":{"required":["name","count"],"type":"object","properties":{"name":{"type":"string"},"count":{"type":"integer","format":"int64"}}},"agent_BadRequest":{"required":["error"],"type":"object","properties":{"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"error":{"type":"string"},"errorType":{"type":"string"}}},"agent_FieldError":{"required":["field","error"],"type":"object","properties":{"field":{"type":"string"},"error":{"type":"string"},"lineNumber":{"type":"integer"},"columnNumber":{"type":"integer"}}},"agent_Unauthorized":{"required":["error"],"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"errorType":{"type":"string"}}},"agent_LicenseError":{"required":["error"],"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"errorType":{"type":"string"}}},"agent_Forbidden":{"required":["error"],"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"errorType":{"type":"string"}}},"agent_NotFound":{"required":["error"],"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"errorType":{"type":"string"}}},"agent_InternalError":{"required":["error"],"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"errorType":{"type":"string"}}}}},"paths":{"/api/v1/environments/{environment}/proxy/api/v1/datasets/tags":{"get":{"tags":["agent_Datasets"],"summary":"Get dataset tags","description":"Get tags sorted by dataset count","operationId":"getDatasetTags","parameters":[{"name":"environment","in":"path","required":true,"schema":{"type":"string"}},{"name":"query","in":"query","description":"Match tag by keyword","required":false,"schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_TagCounts"}}}},"400":{"description":"The request input was invalid","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_BadRequest"}}}},"401":{"description":"Authentication error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_Unauthorized"}}}},"402":{"description":"The purchased Lenses license does not provide access to this feature","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_LicenseError"}}}},"403":{"description":"Authorisation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_Forbidden"}}}},"404":{"description":"The requested resource cannot be found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_NotFound"}}}},"500":{"description":"An internal server error has occurred","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_InternalError"}}}}}}}}}
```

## Get dataset connections

> Get a list of available dataset connections

```json
{"openapi":"3.0.0","info":{"title":"Lenses API","version":"6.1"},"tags":[{"name":"agent_Datasets"}],"servers":[{"url":"{server}","variables":{"server":{"default":"https://api.example.com"}}}],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","description":"The bearer token can be obtained by creating a ServiceAccount.\n"},"cookieAuth":{"type":"apiKey","in":"cookie","name":"session_id","description":"On successful SAML/SSO login, the API will set a cookie with a session id.\n"}},"schemas":{"agent_DatasetConnections":{"type":"object","properties":{"connections":{"type":"array","items":{"$ref":"#/components/schemas/agent_DatasetConnectionResult"}}}},"agent_DatasetConnectionResult":{"required":["name","sourceType","connectionStatus"],"type":"object","properties":{"name":{"type":"string"},"sourceType":{"$ref":"#/components/schemas/agent_SourceType"},"connectionStatus":{"$ref":"#/components/schemas/agent_ConnectionStatus"}}},"agent_SourceType":{"type":"string","enum":["Kafka","SchemaRegistrySubject"]},"agent_ConnectionStatus":{"type":"string","enum":["Green","Yellow","Red"]},"agent_BadRequest":{"required":["error"],"type":"object","properties":{"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"error":{"type":"string"},"errorType":{"type":"string"}}},"agent_FieldError":{"required":["field","error"],"type":"object","properties":{"field":{"type":"string"},"error":{"type":"string"},"lineNumber":{"type":"integer"},"columnNumber":{"type":"integer"}}},"agent_Unauthorized":{"required":["error"],"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"errorType":{"type":"string"}}},"agent_LicenseError":{"required":["error"],"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"errorType":{"type":"string"}}},"agent_Forbidden":{"required":["error"],"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"errorType":{"type":"string"}}},"agent_NotFound":{"required":["error"],"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"errorType":{"type":"string"}}},"agent_InternalError":{"required":["error"],"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"errorType":{"type":"string"}}}}},"paths":{"/api/v1/environments/{environment}/proxy/api/v1/datasets/connections":{"get":{"tags":["agent_Datasets"],"summary":"Get dataset connections","description":"Get a list of available dataset connections","operationId":"getConnectionDatasets","parameters":[{"name":"environment","in":"path","required":true,"schema":{"type":"string"}},{"name":"query","in":"query","description":"Match connection by keyword","required":false,"schema":{"type":"string"}},{"name":"perPage","in":"query","description":"Number of results to be returned. Defaults to 25 if not supplied","required":false,"schema":{"type":"integer"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_DatasetConnections"}}}},"400":{"description":"The request input was invalid","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_BadRequest"}}}},"401":{"description":"Authentication error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_Unauthorized"}}}},"402":{"description":"The purchased Lenses license does not provide access to this feature","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_LicenseError"}}}},"403":{"description":"Authorisation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_Forbidden"}}}},"404":{"description":"The requested resource cannot be found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_NotFound"}}}},"500":{"description":"An internal server error has occurred","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_InternalError"}}}}}}}}}
```

## Get dataset ranged metrics

> get ranged metrics for requested dataset

```json
{"openapi":"3.0.0","info":{"title":"Lenses API","version":"6.1"},"tags":[{"name":"agent_Datasets"}],"servers":[{"url":"{server}","variables":{"server":{"default":"https://api.example.com"}}}],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","description":"The bearer token can be obtained by creating a ServiceAccount.\n"},"cookieAuth":{"type":"apiKey","in":"cookie","name":"session_id","description":"On successful SAML/SSO login, the API will set a cookie with a session id.\n"}},"schemas":{"agent_DailyMessages":{"required":["date"],"type":"object","properties":{"date":{"type":"string","format":"date-time"},"messagesCount":{"type":"integer","format":"int64"}}}}},"paths":{"/api/v1/environments/{environment}/proxy/api/v1/datasets/kafka/{entityName}/messages/metrics":{"get":{"tags":["agent_Datasets"],"summary":"Get dataset ranged metrics","description":"get ranged metrics for requested dataset","operationId":"getDatasetRangedMetrics","parameters":[{"name":"environment","in":"path","required":true,"schema":{"type":"string"}},{"name":"entityName","in":"path","description":"Dataset's entity name","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/agent_DailyMessages"}}}}},"400":{"description":"The request input was invalid","content":{"text/plain":{"schema":{"type":"string"}}}},"401":{"description":"Authentication error","content":{"text/plain":{"schema":{"type":"string"}}}},"402":{"description":"The purchased Lenses license does not provide access to this feature","content":{"text/plain":{"schema":{"type":"string"}}}},"403":{"description":"Authorisation error","content":{"text/plain":{"schema":{"type":"string"}}}},"404":{"description":"The requested resource cannot be found","content":{"text/plain":{"schema":{"type":"string"}}}},"500":{"description":"An internal server error has occurred","content":{"text/plain":{"schema":{"type":"string"}}}}}}}}}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.lenses.io/latest/api-reference/6.1/reference/datasets.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
