ShortUrlsClient

Client for the Kibana Short URLs API.

Kibana URLs may be long and cumbersome; short URLs are much easier to remember and share. Short URLs are created by specifying a locator ID and locator parameters. When a short URL is resolved, the locator ID and locator parameters are used to redirect the user to the right Kibana page.

Note

All Short URL APIs are marked as technical preview in Kibana 9.4 and may change in future releases.

Short URLs are space-scoped saved objects: a short URL created in one space is not visible from another space. Every method accepts an optional space_id to target a specific space.

class kibana._sync.client.short_urls.ShortUrlsClient(client, default_space_id=None, validate_spaces=True)[source]

Bases: NamespaceClient

Client for the Kibana Short URLs API.

Kibana URLs may be long and cumbersome; short URLs are much easier to remember and share. Short URLs are created by specifying a locator ID and locator parameters. When a short URL is resolved, the locator ID and locator parameters are used to redirect the user to the right Kibana page.

All Short URL APIs are marked as Technical Preview in Kibana 9.4 and may change in future releases.

Short URLs are space-scoped saved objects: a short URL created in one space is not visible from another space. Every method accepts an optional space_id to target a specific space (None targets the default space or the space the client is scoped to).

Example

>>> from kibana import Kibana
>>> client = Kibana("http://localhost:5601", api_key="...")
>>>
>>> # Create a short URL using the legacy short URL locator
>>> created = client.short_urls.create(
...     locator_id="LEGACY_SHORT_URL_LOCATOR",
...     params={"url": "/app/dashboards"},
... )
>>> slug = created.body["slug"]
>>>
>>> # Resolve it by slug, then delete it
>>> resolved = client.short_urls.resolve(slug=slug)
>>> client.short_urls.delete(id=resolved.body["id"])

Creating Short URLs

Create a short URL with the create() method:

from kibana import Kibana

client = Kibana("http://localhost:5601", api_key="your_api_key")

# Create a short URL using the legacy short URL locator
created = client.short_urls.create(
    locator_id="LEGACY_SHORT_URL_LOCATOR",
    params={"url": "/app/dashboards"},
)

slug = created.body["slug"]
short_url_id = created.body["id"]
print(f"Short URL: http://localhost:5601/r/s/{slug}")

# Ask Kibana for a human-readable slug instead of a random one
readable = client.short_urls.create(
    locator_id="LEGACY_SHORT_URL_LOCATOR",
    params={"url": "/app/dashboards"},
    human_readable_slug=True,
)

Resolving and Retrieving Short URLs

# Resolve a short URL by its slug
resolved = client.short_urls.resolve(slug=slug)
print(resolved.body["locator"])

# Get a short URL by its ID
short_url = client.short_urls.get(id=short_url_id)

Deleting Short URLs

client.short_urls.delete(id=short_url_id)
__init__(client, default_space_id=None, validate_spaces=True)[source]

Initialize the ShortUrlsClient.

Parameters:
  • client (Kibana) – The parent Kibana client instance to delegate requests to.

  • default_space_id (str | None) – Optional default space ID for all operations.

  • validate_spaces (bool) – Whether to validate space existence before space-scoped operations (default: True).

Example

>>> short_urls_client = ShortUrlsClient(kibana_client)
create(*, locator_id, params, slug=None, human_readable_slug=None, space_id=None, validate_spaces=None)[source]

Create a short URL.

Technical preview in 9.4. Creates a Kibana short URL from a locator ID and its parameters. When the short URL is resolved, the locator redirects the user to the right Kibana page.

Warning: locator params are not validated by Kibana, which allows you to pass arbitrary and ill-formed data into the API that can break Kibana. Make sure any data that you send to the API is properly formed.

Parameters:
  • locator_id (str) – The identifier for the locator (for example, "LEGACY_SHORT_URL_LOCATOR" or "DASHBOARD_APP_LOCATOR").

  • params (dict[str, Any]) – An object which contains all necessary parameters for the given locator to resolve to a Kibana location.

  • slug (str | None) – A custom short URL slug. The slug is the part of the short URL that identifies it. It may consist of latin alphabet letters, numbers, and -._ characters and must be between 3 and 255 characters long.

  • human_readable_slug (bool | None) – When slug is omitted and this is set to True, the API generates a random human-readable slug instead of a random short string.

  • space_id (str | None) – Optional space ID to create the short URL in.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

  • id: The identifier for the short URL

  • slug: The slug that resolves to this short URL

  • locator: The locator id, version and state

  • accessCount / accessDate / createDate: usage metadata

Return type:

ObjectApiResponse containing the created short URL

Raises:

Example

>>> created = client.short_urls.create(
...     locator_id="LEGACY_SHORT_URL_LOCATOR",
...     params={"url": "/app/dashboards"},
...     slug="my-dashboards",
... )
>>> print(created.body["slug"])
my-dashboards
get(*, id, space_id=None, validate_spaces=None)[source]

Get a short URL.

Technical preview in 9.4. Gets a single Kibana short URL by its identifier.

Parameters:
  • id (str) – The identifier for the short URL.

  • space_id (str | None) – Optional space ID to get the short URL from.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse containing the short URL (id, slug, locator, accessCount, accessDate, createDate).

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> url = client.short_urls.get(id="7f2f37bc-...-d64b0e20df6f")
>>> print(url.body["locator"]["id"])
LEGACY_SHORT_URL_LOCATOR
resolve(*, slug, space_id=None, validate_spaces=None)[source]

Resolve a short URL.

Technical preview in 9.4. Resolves a Kibana short URL by its slug and returns the full short URL object, including the locator that can be used to navigate to the target Kibana page.

Parameters:
  • slug (str) – The slug of the short URL.

  • space_id (str | None) – Optional space ID to resolve the short URL in.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse containing the short URL (id, slug, locator, accessCount, accessDate, createDate).

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> resolved = client.short_urls.resolve(slug="my-dashboards")
>>> print(resolved.body["id"])
7f2f37bc-...-d64b0e20df6f
delete(*, id, space_id=None, validate_spaces=None)[source]

Delete a short URL.

Technical preview in 9.4. Deletes a Kibana short URL by its identifier. After deletion, the slug no longer resolves.

Parameters:
  • id (str) – The identifier for the short URL.

  • space_id (str | None) – Optional space ID to delete the short URL from.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse with an empty (null) body on success.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> client.short_urls.delete(id="7f2f37bc-...-d64b0e20df6f")
perform_request(method, path, *, params=None, headers=None, body=None)

Perform an HTTP request via the parent client with space context enhancement.

Parameters:
  • method (str) – HTTP method (GET, POST, PUT, DELETE, etc.)

  • path (str) – API endpoint path

  • params (dict[str, Any] | None) – Query parameters

  • headers (dict[str, str] | None) – Request headers

  • body (dict[str, Any] | None) – Request body

Returns:

API response

Raises:

ApiError – If the API returns an error response (enhanced with space context)

Return type:

ObjectApiResponse[Any]

AsyncShortUrlsClient

Asynchronous version of the ShortUrlsClient for use with async/await syntax.

class kibana._async.client.short_urls.AsyncShortUrlsClient(client, default_space_id=None, validate_spaces=True)[source]

Bases: AsyncNamespaceClient

Async client for the Kibana Short URLs API.

Kibana URLs may be long and cumbersome; short URLs are much easier to remember and share. Short URLs are created by specifying a locator ID and locator parameters. When a short URL is resolved, the locator ID and locator parameters are used to redirect the user to the right Kibana page.

All Short URL APIs are marked as Technical Preview in Kibana 9.4 and may change in future releases.

Short URLs are space-scoped saved objects: a short URL created in one space is not visible from another space. Every method accepts an optional space_id to target a specific space (None targets the default space or the space the client is scoped to).

Example

>>> from kibana import AsyncKibana
>>> client = AsyncKibana("http://localhost:5601", api_key="...")
>>>
>>> # Create a short URL using the legacy short URL locator
>>> created = await client.short_urls.create(
...     locator_id="LEGACY_SHORT_URL_LOCATOR",
...     params={"url": "/app/dashboards"},
... )
>>> slug = created.body["slug"]
>>>
>>> # Resolve it by slug, then delete it
>>> resolved = await client.short_urls.resolve(slug=slug)
>>> await client.short_urls.delete(id=resolved.body["id"])

Usage

The AsyncShortUrlsClient provides the same methods as ShortUrlsClient but all methods are async and must be awaited:

from kibana import AsyncKibana
import asyncio

async def main():
    async with AsyncKibana("http://localhost:5601") as client:
        # Create a short URL (async)
        created = await client.short_urls.create(
            locator_id="LEGACY_SHORT_URL_LOCATOR",
            params={"url": "/app/dashboards"},
        )

        # Resolve it by slug, then delete it (async)
        resolved = await client.short_urls.resolve(
            slug=created.body["slug"]
        )
        await client.short_urls.delete(id=resolved.body["id"])

asyncio.run(main())
__init__(client, default_space_id=None, validate_spaces=True)[source]

Initialize the AsyncShortUrlsClient.

Parameters:
  • client (AsyncKibana) – The parent AsyncKibana client instance to delegate requests to.

  • default_space_id (str | None) – Optional default space ID for all operations.

  • validate_spaces (bool) – Whether to validate space existence before space-scoped operations (default: True).

Example

>>> short_urls_client = AsyncShortUrlsClient(kibana_client)
async create(*, locator_id, params, slug=None, human_readable_slug=None, space_id=None, validate_spaces=None)[source]

Create a short URL.

Technical preview in 9.4. Creates a Kibana short URL from a locator ID and its parameters. When the short URL is resolved, the locator redirects the user to the right Kibana page.

Warning: locator params are not validated by Kibana, which allows you to pass arbitrary and ill-formed data into the API that can break Kibana. Make sure any data that you send to the API is properly formed.

Parameters:
  • locator_id (str) – The identifier for the locator (for example, "LEGACY_SHORT_URL_LOCATOR" or "DASHBOARD_APP_LOCATOR").

  • params (dict[str, Any]) – An object which contains all necessary parameters for the given locator to resolve to a Kibana location.

  • slug (str | None) – A custom short URL slug. The slug is the part of the short URL that identifies it. It may consist of latin alphabet letters, numbers, and -._ characters and must be between 3 and 255 characters long.

  • human_readable_slug (bool | None) – When slug is omitted and this is set to True, the API generates a random human-readable slug instead of a random short string.

  • space_id (str | None) – Optional space ID to create the short URL in.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

  • id: The identifier for the short URL

  • slug: The slug that resolves to this short URL

  • locator: The locator id, version and state

  • accessCount / accessDate / createDate: usage metadata

Return type:

ObjectApiResponse containing the created short URL

Raises:

Example

>>> created = await client.short_urls.create(
...     locator_id="LEGACY_SHORT_URL_LOCATOR",
...     params={"url": "/app/dashboards"},
...     slug="my-dashboards",
... )
>>> print(created.body["slug"])
my-dashboards
async get(*, id, space_id=None, validate_spaces=None)[source]

Get a short URL.

Technical preview in 9.4. Gets a single Kibana short URL by its identifier.

Parameters:
  • id (str) – The identifier for the short URL.

  • space_id (str | None) – Optional space ID to get the short URL from.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse containing the short URL (id, slug, locator, accessCount, accessDate, createDate).

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> url = await client.short_urls.get(id="7f2f37bc-...-d64b0e20df6f")
>>> print(url.body["locator"]["id"])
LEGACY_SHORT_URL_LOCATOR
async resolve(*, slug, space_id=None, validate_spaces=None)[source]

Resolve a short URL.

Technical preview in 9.4. Resolves a Kibana short URL by its slug and returns the full short URL object, including the locator that can be used to navigate to the target Kibana page.

Parameters:
  • slug (str) – The slug of the short URL.

  • space_id (str | None) – Optional space ID to resolve the short URL in.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse containing the short URL (id, slug, locator, accessCount, accessDate, createDate).

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> resolved = await client.short_urls.resolve(slug="my-dashboards")
>>> print(resolved.body["id"])
7f2f37bc-...-d64b0e20df6f
async delete(*, id, space_id=None, validate_spaces=None)[source]

Delete a short URL.

Technical preview in 9.4. Deletes a Kibana short URL by its identifier. After deletion, the slug no longer resolves.

Parameters:
  • id (str) – The identifier for the short URL.

  • space_id (str | None) – Optional space ID to delete the short URL from.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse with an empty (null) body on success.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> await client.short_urls.delete(id="7f2f37bc-...-d64b0e20df6f")
async perform_request(method, path, *, params=None, headers=None, body=None)

Perform an async HTTP request via the parent client with space context enhancement.

Parameters:
  • method (str) – HTTP method (GET, POST, PUT, DELETE, etc.)

  • path (str) – API endpoint path

  • params (dict[str, Any] | None) – Query parameters

  • headers (dict[str, str] | None) – Request headers

  • body (dict[str, Any] | None) – Request body

Returns:

API response

Raises:

ApiError – If the API returns an error response (enhanced with space context)

Return type:

ObjectApiResponse[Any]