Get service accounts API

Get service accounts API

New API reference

For the most up-to-date API details, refer to Security APIs.

Retrieves information about service accounts.

Currently, only the elastic/fleet-server service account is available.

Request

GET /_security/service

GET /_security/service/<namespace>

GET /_security/service/<namespace>/<service>

Prerequisites

  • To use this API, you must have at least the manage_service_account cluster privilege.

Description

This API returns a list of service accounts that match the provided path parameter(s).

Path parameters

namespace

(Optional, string) Name of the namespace. Omit this parameter to retrieve information about all service accounts. If you omit this parameter, you must also omit the service parameter.

service

(Optional, string) Name of the service name. Omit this parameter to retrieve information about all service accounts that belong to the specified namespace.

Response body

A successful call returns a JSON object of service accounts. The API returns an empty object if no service account is found.

Examples

To following request retrieves a service account for the elastic/fleet-server service account:

  1. resp = client.security.get_service_accounts(
  2. namespace="elastic",
  3. service="fleet-server",
  4. )
  5. print(resp)
  1. const response = await client.security.getServiceAccounts({
  2. namespace: "elastic",
  3. service: "fleet-server",
  4. });
  5. console.log(response);
  1. GET /_security/service/elastic/fleet-server
  1. {
  2. "elastic/fleet-server": {
  3. "role_descriptor": {
  4. "cluster": [
  5. "monitor",
  6. "manage_own_api_key",
  7. "read_fleet_secrets"
  8. ],
  9. "indices": [
  10. {
  11. "names": [
  12. "logs-*",
  13. "metrics-*",
  14. "traces-*",
  15. ".logs-endpoint.diagnostic.collection-*",
  16. ".logs-endpoint.action.responses-*",
  17. ".logs-endpoint.heartbeat-*"
  18. ],
  19. "privileges": [
  20. "write",
  21. "create_index",
  22. "auto_configure"
  23. ],
  24. "allow_restricted_indices": false
  25. },
  26. {
  27. "names": [
  28. "profiling-*"
  29. ],
  30. "privileges": [
  31. "read",
  32. "write"
  33. ],
  34. "allow_restricted_indices": false
  35. },
  36. {
  37. "names": [
  38. "traces-apm.sampled-*"
  39. ],
  40. "privileges": [
  41. "read",
  42. "monitor",
  43. "maintenance"
  44. ],
  45. "allow_restricted_indices": false
  46. },
  47. {
  48. "names": [
  49. ".fleet-secrets*"
  50. ],
  51. "privileges": [
  52. "read"
  53. ],
  54. "allow_restricted_indices": true
  55. },
  56. {
  57. "names": [
  58. ".fleet-actions*"
  59. ],
  60. "privileges": [
  61. "read",
  62. "write",
  63. "monitor",
  64. "create_index",
  65. "auto_configure",
  66. "maintenance"
  67. ],
  68. "allow_restricted_indices": true
  69. },
  70. {
  71. "names": [
  72. ".fleet-agents*"
  73. ],
  74. "privileges": [
  75. "read",
  76. "write",
  77. "monitor",
  78. "create_index",
  79. "auto_configure",
  80. "maintenance"
  81. ],
  82. "allow_restricted_indices": true
  83. },
  84. {
  85. "names": [
  86. ".fleet-artifacts*"
  87. ],
  88. "privileges": [
  89. "read",
  90. "write",
  91. "monitor",
  92. "create_index",
  93. "auto_configure",
  94. "maintenance"
  95. ],
  96. "allow_restricted_indices": true
  97. },
  98. {
  99. "names": [
  100. ".fleet-enrollment-api-keys*"
  101. ],
  102. "privileges": [
  103. "read",
  104. "write",
  105. "monitor",
  106. "create_index",
  107. "auto_configure",
  108. "maintenance"
  109. ],
  110. "allow_restricted_indices": true
  111. },
  112. {
  113. "names": [
  114. ".fleet-policies*"
  115. ],
  116. "privileges": [
  117. "read",
  118. "write",
  119. "monitor",
  120. "create_index",
  121. "auto_configure",
  122. "maintenance"
  123. ],
  124. "allow_restricted_indices": true
  125. },
  126. {
  127. "names": [
  128. ".fleet-policies-leader*"
  129. ],
  130. "privileges": [
  131. "read",
  132. "write",
  133. "monitor",
  134. "create_index",
  135. "auto_configure",
  136. "maintenance"
  137. ],
  138. "allow_restricted_indices": true
  139. },
  140. {
  141. "names": [
  142. ".fleet-servers*"
  143. ],
  144. "privileges": [
  145. "read",
  146. "write",
  147. "monitor",
  148. "create_index",
  149. "auto_configure",
  150. "maintenance"
  151. ],
  152. "allow_restricted_indices": true
  153. },
  154. {
  155. "names": [
  156. ".fleet-fileds*"
  157. ],
  158. "privileges": [
  159. "read",
  160. "write",
  161. "monitor",
  162. "create_index",
  163. "auto_configure",
  164. "maintenance"
  165. ],
  166. "allow_restricted_indices": true
  167. },
  168. {
  169. "names": [
  170. "synthetics-*"
  171. ],
  172. "privileges": [
  173. "read",
  174. "write",
  175. "create_index",
  176. "auto_configure"
  177. ],
  178. "allow_restricted_indices": false
  179. }
  180. ],
  181. "applications": [
  182. {
  183. "application": "kibana-*",
  184. "privileges": [
  185. "reserved_fleet-setup"
  186. ],
  187. "resources": [
  188. "*"
  189. ]
  190. }
  191. ],
  192. "run_as": [],
  193. "metadata": {},
  194. "transient_metadata": {
  195. "enabled": true
  196. }
  197. }
  198. }
  199. }

Omit the namespace and service to retrieve all service accounts:

  1. resp = client.security.get_service_accounts()
  2. print(resp)
  1. const response = await client.security.getServiceAccounts();
  2. console.log(response);
  1. GET /_security/service