# List application fields

List the fields an application's data can be queried by, with their types. The list holds the fields seen in the application's logs, spans, exceptions or web events in the last 6 hours. The response lists every field at once. An application that received no data in the last 6 hours returns an empty list.

[endpoint]
method = "GET"
base_url = "https://errors.betterstack.com"
path = "/api/v4/applications/{application_id}/fields"

[[path_param]]
name = "application_id"
required = true
type = "string"
description = "Application whose fields are listed."

[[query_param]]
name = "source_type"
default = "logs"
type = "string"
description = "The kind of data whose fields are listed. Possible values: `logs`, `spans`, `exceptions`, `web_events`."

[[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 list of application fields."
body = '''
{
  "data": [
    {
      "id": "123456789",
      "type": "source_field",
      "attributes": {
        "path": "error.message",
        "path_parts": [
          "'error'",
          "'message'"
        ],
        "type": "String"
      }
    }
  ]
}
'''

[[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 application doesn't exist, or the token can't access it."
body = '''
{
  "errors": "Resource with the provided ID was not found"
}
'''

[[response]]
status = 422
description = "The `source_type` parameter isn't `logs`, `spans`, `exceptions` or `web_events`, or the application has no data of that type. `invalid_values` names it."
body = '''
{
  "errors": "Sorry, some values are incorrect",
  "invalid_values": {
    "source_type": "This source has no spans data."
  }
}
'''
[/responses]

[params]
title = "Response attributes"

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

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

[[param]]
name = "path"
type = "string"
description = "The field's path in the log or span, such as `error.message`."

[[param]]
name = "path_parts"
type = "array of strings"
description = "The path split into segments, each single-quoted, ready to pass to `JSONExtract` in a query, such as `'error', 'message'`."

[[param]]
name = "attributes.type"
type = "string"
description = "The field's data type, such as `String` or `Int64`."
[/params]

#### Example cURL

[code-tabs]
```shell
[label List application fields]
curl --request GET \
  --url https://errors.betterstack.com/api/v4/applications/1234/fields \
  --header "Authorization: Bearer $TOKEN"
```
```shell
[label Web event fields]
curl --request GET \
  --url "https://errors.betterstack.com/api/v4/applications/1234/fields?source_type=web_events" \
  --header "Authorization: Bearer $TOKEN"
```
[/code-tabs]
