AWS Cost Explorer Service
Cost Management APIs

GetTags

Queries for available tag keys and tag values for a specified period. You can search the tag values for an arbitrary string.

Request Syntax

{ "NextPageToken": "string", "SearchString": "string", "TagKey": "string", "TimePeriod": { "End": "string", "Start": "string" } }

Request Parameters

For information about the parameters that are common to all actions, see Common Parameters.

The request accepts the following data in JSON format.

NextPageToken

The token to retrieve the next set of results. AWS provides the token when the response from a previous call has more results than the maximum page size.

Type: String

Required: No

SearchString

The value that you want to search for.

Type: String

Required: No

TagKey

The key of the tag that you want to return values for.

Type: String

Required: No

TimePeriod

The start and end dates for retrieving the dimension values. The start date is inclusive, but the end date is exclusive. For example, if start is 2017-01-01 and end is 2017-05-01, then the cost and usage data is retrieved from 2017-01-01 up to and including 2017-04-30 but not including 2017-05-01.

Type: DateInterval object

Required: Yes

Response Syntax

{ "NextPageToken": "string", "ReturnSize": number, "Tags": [ "string" ], "TotalSize": number }

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

NextPageToken

The token for the next set of retrievable results. AWS provides the token when the response from a previous call has more results than the maximum page size.

Type: String

ReturnSize

The number of query results that AWS returns at a time.

Type: Integer

Tags

The tags that match your request.

Type: Array of strings

TotalSize

The total number of query results.

Type: Integer

Errors

For information about the errors that are common to all actions, see Common Errors.

BillExpirationException

The requested report expired. Update the date interval and try again.

HTTP Status Code: 400

DataUnavailableException

The requested data is unavailable.

HTTP Status Code: 400

InvalidNextTokenException

The pagination token is invalid. Try again without a pagination token.

HTTP Status Code: 400

LimitExceededException

You made too many calls in a short period of time. Try again later.

HTTP Status Code: 400

RequestChangedException

Your request parameters changed between pages. Try again with the old parameters or without a pagination token.

HTTP Status Code: 400

Example

The following example shows how to retrieve the list of tag keys using the GetTags operation:

Sample Request

POST / HTTP/1.1 Host: ce.us-east-1.amazonaws.com x-amz-Date: <Date> Authorization: AWS4-HMAC-SHA256 Credential=<Credential>, SignedHeaders=contenttype;date;host;user-agent;x-amz-date;x-amz-target;x-amzn-requestid,Signature=<Signature> User-Agent: <UserAgentString> Content-Type: application/x-amz-json-1.1 Content-Length: <PayloadSizeBytes> Connection: Keep-Alive X-Amz-Target: AWSInsightsIndexService.GetTags { "TimePeriod": { "Start": "2017-01-01", "End": "2017-05-18" }, "TagKey": "Project", "SearchString": "secretProject" }

Sample Response

HTTP/1.1 200 OK x-amzn-RequestId: <RequestId> Content-Type: application/x-amz-json-1.1 Content-Length: <PayloadSizeBytes> Date: <Date> { "ReturnSize": 2, "Tags": [ secretProject1", "secretProject2" ], "TotalSize": 2 }

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following: