get-service-accounts.asciidoc 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. [role="xpack"]
  2. [[security-api-get-service-accounts]]
  3. === Get service accounts API
  4. beta::[]
  5. ++++
  6. <titleabbrev>Get service accounts</titleabbrev>
  7. ++++
  8. Retrieves information about <<service-accounts,service accounts>>.
  9. NOTE: Currently, only the `elastic/fleet-server` service account is available.
  10. [[security-api-get-service-accounts-request]]
  11. ==== {api-request-title}
  12. `GET /_security/service`
  13. `GET /_security/service/<namespace>`
  14. `GET /_security/service/<namespace>/<service>`
  15. [[security-api-get-service-accounts-prereqs]]
  16. ==== {api-prereq-title}
  17. * To use this API, you must have at least the `manage_service_account`
  18. <<privileges-list-cluster,cluster privilege>>.
  19. [[security-api-get-service-accounts-desc]]
  20. ==== {api-description-title}
  21. include::../../security/authentication/service-accounts.asciidoc[tag=service-accounts-tls]
  22. [[security-api-get-service-accounts-path-params]]
  23. ==== {api-path-parms-title}
  24. `namespace`::
  25. (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.
  26. `service`::
  27. (Optional, string) Name of the service name. Omit this parameter to
  28. retrieve information about all service accounts that belong to the specified
  29. `namespace`.
  30. [[security-api-get-service-accounts-response-body]]
  31. ==== {api-response-body-title}
  32. A successful call returns a JSON object of service accounts. The API returns an
  33. empty object if no service account is found.
  34. [[security-api-get-service-accounts-example]]
  35. ==== {api-examples-title}
  36. To following request retrieves a service account for the `elastic/fleet-server`
  37. service account:
  38. [source,console]
  39. ----
  40. GET /_security/service/elastic/fleet-server
  41. ----
  42. [source,console-result]
  43. ----
  44. {
  45. "elastic/fleet-server": {
  46. "role_descriptor": {
  47. "cluster": [
  48. "monitor",
  49. "manage_own_api_key"
  50. ],
  51. "indices": [
  52. {
  53. "names": [
  54. "logs-*",
  55. "metrics-*",
  56. "traces-*",
  57. "synthetics-*",
  58. ".logs-endpoint.diagnostic.collection-*"
  59. ],
  60. "privileges": [
  61. "write",
  62. "create_index",
  63. "auto_configure"
  64. ],
  65. "allow_restricted_indices": false
  66. },
  67. {
  68. "names": [
  69. ".fleet-*"
  70. ],
  71. "privileges": [
  72. "read",
  73. "write",
  74. "monitor",
  75. "create_index",
  76. "auto_configure"
  77. ],
  78. "allow_restricted_indices": false
  79. }
  80. ],
  81. "applications": [],
  82. "run_as": [],
  83. "metadata": {},
  84. "transient_metadata": {
  85. "enabled": true
  86. }
  87. }
  88. }
  89. }
  90. ----
  91. Omit the `namespace` and `service` to retrieve all service accounts:
  92. [source,console]
  93. ----
  94. GET /_security/service
  95. ----