# Get a service

Get one service a source detected in its traces or logs.

[endpoint]
method = "GET"
base_url = "https://telemetry.betterstack.com"
path = "/api/v4/sources/{source_id}/services/{id}"

[[path_param]]
name = "source_id"
required = true
type = "string"
description = "Source that detected the service. Get its ID via [List sources](/docs/logs/api/list-all-existing-sources/)."

[[path_param]]
name = "id"
required = true
type = "string"
description = "The service's ID, as listing a source's services returns it."

[[query_param]]
name = "team_id"
type = "string"
description = "Team to use, such as `t123`. Get the ID via [List teams](/docs/uptime/api/teams/list/). Required when you can access more than one team."

[[header]]
name = "Authorization"
description = "Bearer `$TOKEN`"
required = true
type = "string"
[/endpoint]

[responses]
[[response]]
status = 200
description = "Returns the service."
body = '''
{
  "data": {
    "id": "123456789",
    "type": "service",
    "attributes": {
      "source_id": "123456",
      "name": "checkout",
      "namespace": null,
      "platform": "postgresql",
      "platform_title": "PostgreSQL",
      "matching": "exact",
      "source_types": [
        "logs",
        "spans"
      ],
      "name_fields": {
        "logs": [
          "kubernetes.container_name"
        ],
        "spans": [
          "resource.service.name"
        ]
      },
      "kubernetes_labels": {
        "app": "checkout"
      },
      "created_at": "2026-11-10T08:12:44.123Z",
      "last_seen_at": "2026-11-22T17:03:56.000Z"
    }
  }
}
'''

[[response]]
status = 401
description = "The API token is missing or invalid."
body = '''
{
  "errors": "Invalid Team API token. How to find your Team API token: https://betterstack.com/docs/logs/api/getting-started/#obtaining-a-logtail-api-token"
}
'''

[[response]]
status = 403
description = "Your role doesn't allow viewing this, or the token can't be used for this API."

[[response]]
status = 404
description = "The `source_id` value isn't one of your sources, or the source has no service with that ID."
body = '''
{
  "errors": "Resource with the provided ID was not found"
}
'''
[/responses]

[params]
title = "Response attributes"

[[param]]
name = "id"
type = "string"
description = "The ID of the service."

[[param]]
name = "type"
type = "string"
description = "Always `service`."

[[param]]
name = "source_id"
type = "string"
description = "The ID of the source that detected the service."

[[param]]
name = "name"
type = "string"
description = "The service's name."

[[param]]
name = "namespace"
type = "string or null"
description = "The Kubernetes namespace of a service named `<namespace>/<kind>/<name>`. `null` for other services."

[[param]]
name = "platform"
type = "string or null"
description = "What the service runs, such as `postgresql`, `nginx` or `rails`. `null` when it isn't known."

[[param]]
name = "platform_title"
type = "string or null"
description = "The platform's name, such as `PostgreSQL`. `null` when the platform isn't known."

[[param]]
name = "matching"
type = "string"
description = "How the name matches the service field of logs, spans and metrics.<br/>Valid values:<br/>`exact`: Matches the name itself.<br/>`prefix`: Matches every name that starts with it.<br/>`workload`: Matches a Kubernetes service named `<namespace>/<kind>/<name>` by its full name or by `<name>` alone."

[[param]]
name = "source_types"
type = "array of strings"
description = "The kinds of data the service was seen in, such as `logs`, `spans` or `metrics`."

[[param]]
name = "name_fields"
type = "object"
description = "The fields the service's name is read from, as lists keyed by the kind of data, such as `logs` or `spans`. Set them in the source's settings under **Extract services**. Each value is a list of strings."

[[param]]
name = "kubernetes_labels"
type = "object"
description = "The Kubernetes labels of the service's workload, without the ones Kubernetes adds itself, such as `pod-template-hash`. An empty object for a service outside Kubernetes. Each value is a string."

[[param]]
name = "created_at"
type = "datetime"
description = "When the service was first detected. In ISO 8601 format, such as `2026-07-01T12:00:00Z`."

[[param]]
name = "last_seen_at"
type = "datetime or null"
description = "When the service was last seen in the source's data. `null` when it isn't known. In ISO 8601 format, such as `2026-07-01T12:00:00Z`."
[/params]

#### Example cURL

```shell
[label Get a service]
curl --request GET \
  --url https://telemetry.betterstack.com/api/v4/sources/123456/services/789 \
  --header "Authorization: Bearer $TOKEN"
```
