Accessing search API using api key and acces token-based authentication

Hi, I need some help accessing the Search API. I Have elastic cloud setup as azure managed service. I can access the cloud Service API using API key-based authentication:

curl -X GET -H "Authorization: ApiKey <api_key>" https://api.elastic-cloud.com/api/v1/deployments

but its not clear how to access data through the Search API

  1. What baseurl do I use? Is it the console host endpoint? e.g., https://xxx.es.australiaeast.azure.elastic-cloud.com , i.e.,
curl -X GET "https://xxx.es.australiaeast.azure.elastic-cloud.com:<port>/<index>/_search" -H 'Content-Type: application/json' -d '{...}'
  1. Can I use the same api key or do I have to generate a new key using the Create API key API? and how do I authenticate the create api key request?
  2. For OAuth2 flow, how do I create a user/password (or client key/secret) that I can then exchange for an access token, ie
curl -X POST "<base_url>/_security/oauth2/token" -H 'Content-Type: application/json' -d' 
{ 
  "grant_type" : "password", 
  "username" : "<username>", 
  "password" : "<password>" 
} 

curl -X POST "<base_url>/_security/oauth2/token" -H 'Content-Type: application/json' -d' 
{ 
  "grant_type" : "client_credentials", 
  "username" : "<key>", 
  "password" : "<secret>" 
}

Thanks!

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.