Workspaces APIs

Introduced 2.18

The Workspaces API provides a set of endpoints for managing workspaces in OpenSearch Dashboards.

List Workspaces API

You can use the following endpoint to retrieve a list of workspaces:

  1. POST <osd host>:<port>/api/workspaces/_list

copy

The following table lists the available path parameters.

ParameterData typeRequiredDescription
searchStringOptionalA query string used to filter workspaces with simple query syntax, for example, simple_query_string.
searchFieldsArrayOptionalSpecifies which fields to perform the search query against.
sortFieldStringOptionalThe field name to use for sorting results.
sortOrderStringOptionalSpecifies ascending or descending sort order.
perPageNumberOptionalThe number of workspace results per page.
pageNumberOptionalThe number of pages of results to retrieve.
permissionModesArrayOptionalA list of permissions to filter by.

Example request

  1. POST /api/workspaces/_list

copy

The following example response shows a successful API call:

  1. {
  2. "success": true,
  3. "result": {
  4. "page": 1,
  5. "per_page": 20,
  6. "total": 3,
  7. "workspaces": [
  8. {
  9. "name": "test1",
  10. "features": [
  11. "use-case-all"
  12. ],
  13. "id": "hWNZls"
  14. },
  15. {
  16. "name": "test2",
  17. "features": [
  18. "use-case-observability"
  19. ],
  20. "id": "SnkOPt"
  21. }
  22. ]
  23. }
  24. }

copy

Get Workspaces API

You can use the following endpoint to retrieve a single workspace:

  1. GET <osd host>:<port>/api/workspaces/<id>

copy

The following table lists the available path parameters. All path parameters are required.

ParameterData typeRequiredDescription
<id>StringRequiredIdentifies the unique workspace to be retrieved.

Example request

  1. GET /api/workspaces/SnkOPt

copy

The following example response shows a successful API call:

  1. {
  2. "success": true,
  3. "result": {
  4. "name": "test2",
  5. "features": ["use-case-all"],
  6. "id": "SnkOPt"
  7. }
  8. }

copy

Create Workspaces API

You can use the following endpoint to create a workspace:

  1. POST <osd host>:<port>/api/workspaces

copy

The following table lists the available path parameters.

ParameterData typeRequiredDescription
attributesObjectRequiredDefines the workspace attributes.
permissionsObjectOptionalSpecifies the permissions for the workspace.

Example request

  1. POST api/workspaces
  2. {
  3. "attributes": {
  4. "name": "test4",
  5. "description": "test4"
  6. }
  7. }

copy

The following example response shows a successful API call:

  1. {
  2. "success": true,
  3. "result": {
  4. "id": "eHVoCJ"
  5. }
  6. }

copy

Update Workspaces API

You can use the following endpoint to update the attributes and permissions for a workspace:

  1. PUT <osd host>:<port>/api/workspaces/<id>

copy

The following table lists the available path parameters.

ParameterData typeRequiredDescription
<id>StringRequiredIdentifies the unique workspace to be retrieved.
attributesObjectRequiredDefines the workspace attributes.
permissionsObjectOptionalSpecifies the permissions for the workspace.

Example request

  1. PUT api/workspaces/eHVoCJ
  2. {
  3. "attributes": {
  4. "name": "test4",
  5. "description": "test update"
  6. }
  7. }

copy

The following example response shows a successful API call:

  1. {
  2. "success": true,
  3. "result": true
  4. }

copy

Delete Workspaces API

You can use the following endpoint to delete a workspace:

  1. DELETE <osd host>:<port>/api/workspaces/<id>

copy

The following table lists the available path parameters. All path parameters are required.

ParameterData typeRequiredDescription
<id>StringRequiredIdentifies the unique workspace to be retrieved.

Example request

  1. DELETE api/workspaces/eHVoCJ

copy

The following example response shows a successful API call:

  1. {
  2. "success": true,
  3. "result": true
  4. }

copy

Duplicate Saved Objects Workspaces API

You can use the following endpoint to copy saved objects between workspaces:

  1. POST <osd host>:<port>/api/workspaces/_duplicate_saved_objects

copy

The following table lists the available path parameters.

ParameterData typeRequiredDescription
objectsArrayRequiredSpecifies the saved objects to be duplicated.
targetWorkspaceStringRequiredIdentifies the destination workspace for copying.
includeReferencesDeepBooleanOptionalDetermines whether to copy all referenced objects to the target workspace. Default is true.

The following table lists the attributes of the object in the objects parameter.

ParameterData typeRequiredDescription
typeStringRequiredDefines the saved object classification, such as index-pattern, config, or dashboard.
idStringRequiredThe ID of the saved object.

Example request

  1. POST api/workspaces/_duplicate_saved_objects
  2. {
  3. "objects": [
  4. {
  5. "type": "index-pattern",
  6. "id": "619cc200-ecd0-11ee-95b1-e7363f9e289d"
  7. }
  8. ],
  9. "targetWorkspace": "9gt4lB"
  10. }

copy

The following example response shows a successful API call:

  1. {
  2. "successCount": 1,
  3. "success": true,
  4. "successResults": [
  5. {
  6. "type": "index-pattern",
  7. "id": "619cc200-ecd0-11ee-95b1-e7363f9e289d",
  8. "meta": {
  9. "title": "test*",
  10. "icon": "indexPatternApp"
  11. },
  12. "destinationId": "f4b724fd-9647-4bbf-bf59-610b43a62c75"
  13. }
  14. ]
  15. }

copy

Associate Saved Objects Workspaces API

You can use the following endpoint to associate saved objects with a workspace:

  1. POST <osd host>:<port>/api/workspaces/_associate

copy

The following table lists the available path parameters.

ParameterData typeRequiredDescription
workspaceIdStringRequiredIdentifies the target workspace for object association.
savedObjectsArrayRequiredSpecifies the list of saved objects to be copied.

The following table lists the attributes of the object in the objects parameter.

ParameterData typeRequiredDescription
typeStringRequiredDefines the saved object classification, such as index-pattern, config, or dashboard.
idStringRequiredThe ID of the saved object.

Example request

  1. POST api/workspaces/_associate
  2. {
  3. "objects": [
  4. {
  5. "type": "index-pattern",
  6. "id": "619cc200-ecd0-11ee-95b1-e7363f9e289d"
  7. }
  8. ],
  9. "targetWorkspace": "9gt4lB"
  10. }

copy

The following example response shows a successful API call:

  1. {
  2. "success": true,
  3. "result": [
  4. {
  5. "id": "619cc200-ecd0-11ee-95b1-e7363f9e289d",
  6. }
  7. ]
  8. }

copy

Dissociate Saved Objects Workspaces API

You can use the following endpoint to dissociate saved objects from a workspace:

  1. POST <osd host>:<port>/api/workspaces/_dissociate

copy

The following table lists the available path parameters.

ParameterData typeRequiredDescription
workspaceIdStringRequiredThe target workspace with which to associate the objects.
savedObjectsArrayRequiredA list of saved objects to copy.

The following table lists the attributes of the savedObjects parameter.

ParameterData typeRequiredDescription
typeStringRequiredThe type of the saved object, such as index-pattern, config, or dashboard.
idStringRequiredThe ID of the saved object.

Example request

  1. POST api/workspaces/_dissociate
  2. {
  3. "objects": [
  4. {
  5. "type": "index-pattern",
  6. "id": "619cc200-ecd0-11ee-95b1-e7363f9e289d"
  7. }
  8. ],
  9. "targetWorkspace": "9gt4lB"
  10. }

copy

The following example response shows a successful API call:

  1. {
  2. "success": true,
  3. "result": [
  4. {
  5. "id": "619cc200-ecd0-11ee-95b1-e7363f9e289d",
  6. }
  7. ]
  8. }

copy