

# GetExecutionHistory
<a name="API_GetExecutionHistory"></a>

Returns the history of the specified execution as a list of events. By default, the results are returned in ascending order of the `timeStamp` of the events. Use the `reverseOrder` parameter to get the latest events first.

If `nextToken` is returned, there are more results available. The value of `nextToken` is a unique pagination token for each page. Make the call again using the returned token to retrieve the next page. Keep all other arguments unchanged. Each pagination token expires after 24 hours. Using an expired pagination token will return an *HTTP 400 InvalidToken* error.

This API action is not supported by `EXPRESS` state machines.

## Request Syntax
<a name="API_GetExecutionHistory_RequestSyntax"></a>

```
{
   "executionArn": "string",
   "includeExecutionData": boolean,
   "maxResults": number,
   "nextToken": "string",
   "reverseOrder": boolean
}
```

## Request Parameters
<a name="API_GetExecutionHistory_RequestParameters"></a>

For information about the parameters that are common to all actions, see [Common Parameters](CommonParameters.md).

The request accepts the following data in JSON format.

 ** [executionArn](#API_GetExecutionHistory_RequestSyntax) **   <a name="StepFunctions-GetExecutionHistory-request-executionArn"></a>
The Amazon Resource Name (ARN) of the execution.  
Type: String  
Length Constraints: Minimum length of 1. Maximum length of 256.  
Required: Yes

 ** [includeExecutionData](#API_GetExecutionHistory_RequestSyntax) **   <a name="StepFunctions-GetExecutionHistory-request-includeExecutionData"></a>
You can select whether execution data (input or output of a history event) is returned. The default is `true`.  
Type: Boolean  
Required: No

 ** [maxResults](#API_GetExecutionHistory_RequestSyntax) **   <a name="StepFunctions-GetExecutionHistory-request-maxResults"></a>
The maximum number of results that are returned per call. You can use `nextToken` to obtain further pages of results. The default is 100 and the maximum allowed page size is 1000. A value of 0 uses the default.  
This is only an upper limit. The actual number of results returned per call might be fewer than the specified maximum.  
Type: Integer  
Valid Range: Minimum value of 0. Maximum value of 1000.  
Required: No

 ** [nextToken](#API_GetExecutionHistory_RequestSyntax) **   <a name="StepFunctions-GetExecutionHistory-request-nextToken"></a>
If `nextToken` is returned, there are more results available. The value of `nextToken` is a unique pagination token for each page. Make the call again using the returned token to retrieve the next page. Keep all other arguments unchanged. Each pagination token expires after 24 hours. Using an expired pagination token will return an *HTTP 400 InvalidToken* error.  
Type: String  
Length Constraints: Minimum length of 1. Maximum length of 1024.  
Required: No

 ** [reverseOrder](#API_GetExecutionHistory_RequestSyntax) **   <a name="StepFunctions-GetExecutionHistory-request-reverseOrder"></a>
Lists events in descending order of their `timeStamp`.  
Type: Boolean  
Required: No

## Response Syntax
<a name="API_GetExecutionHistory_ResponseSyntax"></a>

```
{
   "events": [ 
      { 
         "activityFailedEventDetails": { 
            "cause": "string",
            "error": "string"
         },
         "activityScheduledEventDetails": { 
            "heartbeatInSeconds": number,
            "input": "string",
            "inputDetails": { 
               "truncated": boolean
            },
            "resource": "string",
            "timeoutInSeconds": number
         },
         "activityScheduleFailedEventDetails": { 
            "cause": "string",
            "error": "string"
         },
         "activityStartedEventDetails": { 
            "workerName": "string"
         },
         "activitySucceededEventDetails": { 
            "output": "string",
            "outputDetails": { 
               "truncated": boolean
            }
         },
         "activityTimedOutEventDetails": { 
            "cause": "string",
            "error": "string"
         },
         "evaluationFailedEventDetails": { 
            "cause": "string",
            "error": "string",
            "location": "string",
            "state": "string"
         },
         "executionAbortedEventDetails": { 
            "cause": "string",
            "error": "string"
         },
         "executionFailedEventDetails": { 
            "cause": "string",
            "error": "string"
         },
         "executionRedrivenEventDetails": { 
            "redriveCount": number
         },
         "executionStartedEventDetails": { 
            "input": "string",
            "inputDetails": { 
               "truncated": boolean
            },
            "roleArn": "string",
            "stateMachineAliasArn": "string",
            "stateMachineVersionArn": "string"
         },
         "executionSucceededEventDetails": { 
            "output": "string",
            "outputDetails": { 
               "truncated": boolean
            }
         },
         "executionTimedOutEventDetails": { 
            "cause": "string",
            "error": "string"
         },
         "id": number,
         "lambdaFunctionFailedEventDetails": { 
            "cause": "string",
            "error": "string"
         },
         "lambdaFunctionScheduledEventDetails": { 
            "input": "string",
            "inputDetails": { 
               "truncated": boolean
            },
            "resource": "string",
            "taskCredentials": { 
               "roleArn": "string"
            },
            "timeoutInSeconds": number
         },
         "lambdaFunctionScheduleFailedEventDetails": { 
            "cause": "string",
            "error": "string"
         },
         "lambdaFunctionStartFailedEventDetails": { 
            "cause": "string",
            "error": "string"
         },
         "lambdaFunctionSucceededEventDetails": { 
            "output": "string",
            "outputDetails": { 
               "truncated": boolean
            }
         },
         "lambdaFunctionTimedOutEventDetails": { 
            "cause": "string",
            "error": "string"
         },
         "mapIterationAbortedEventDetails": { 
            "index": number,
            "name": "string"
         },
         "mapIterationFailedEventDetails": { 
            "index": number,
            "name": "string"
         },
         "mapIterationStartedEventDetails": { 
            "index": number,
            "name": "string"
         },
         "mapIterationSucceededEventDetails": { 
            "index": number,
            "name": "string"
         },
         "mapRunFailedEventDetails": { 
            "cause": "string",
            "error": "string"
         },
         "mapRunRedrivenEventDetails": { 
            "mapRunArn": "string",
            "redriveCount": number
         },
         "mapRunStartedEventDetails": { 
            "mapRunArn": "string"
         },
         "mapStateStartedEventDetails": { 
            "length": number
         },
         "previousEventId": number,
         "stateEnteredEventDetails": { 
            "input": "string",
            "inputDetails": { 
               "truncated": boolean
            },
            "name": "string"
         },
         "stateExitedEventDetails": { 
            "assignedVariables": { 
               "string" : "string" 
            },
            "assignedVariablesDetails": { 
               "truncated": boolean
            },
            "name": "string",
            "output": "string",
            "outputDetails": { 
               "truncated": boolean
            }
         },
         "taskFailedEventDetails": { 
            "cause": "string",
            "error": "string",
            "resource": "string",
            "resourceType": "string"
         },
         "taskScheduledEventDetails": { 
            "heartbeatInSeconds": number,
            "parameters": "string",
            "region": "string",
            "resource": "string",
            "resourceType": "string",
            "taskCredentials": { 
               "roleArn": "string"
            },
            "timeoutInSeconds": number
         },
         "taskStartedEventDetails": { 
            "resource": "string",
            "resourceType": "string"
         },
         "taskStartFailedEventDetails": { 
            "cause": "string",
            "error": "string",
            "resource": "string",
            "resourceType": "string"
         },
         "taskSubmitFailedEventDetails": { 
            "cause": "string",
            "error": "string",
            "resource": "string",
            "resourceType": "string"
         },
         "taskSubmittedEventDetails": { 
            "output": "string",
            "outputDetails": { 
               "truncated": boolean
            },
            "resource": "string",
            "resourceType": "string"
         },
         "taskSucceededEventDetails": { 
            "output": "string",
            "outputDetails": { 
               "truncated": boolean
            },
            "resource": "string",
            "resourceType": "string"
         },
         "taskTimedOutEventDetails": { 
            "cause": "string",
            "error": "string",
            "resource": "string",
            "resourceType": "string"
         },
         "timestamp": number,
         "type": "string"
      }
   ],
   "nextToken": "string"
}
```

## Response Elements
<a name="API_GetExecutionHistory_ResponseElements"></a>

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

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

 ** [events](#API_GetExecutionHistory_ResponseSyntax) **   <a name="StepFunctions-GetExecutionHistory-response-events"></a>
The list of events that occurred in the execution.  
Type: Array of [HistoryEvent](API_HistoryEvent.md) objects

 ** [nextToken](#API_GetExecutionHistory_ResponseSyntax) **   <a name="StepFunctions-GetExecutionHistory-response-nextToken"></a>
If `nextToken` is returned, there are more results available. The value of `nextToken` is a unique pagination token for each page. Make the call again using the returned token to retrieve the next page. Keep all other arguments unchanged. Each pagination token expires after 24 hours. Using an expired pagination token will return an *HTTP 400 InvalidToken* error.  
Type: String  
Length Constraints: Minimum length of 1. Maximum length of 1024.

## Errors
<a name="API_GetExecutionHistory_Errors"></a>

For information about the errors that are common to all actions, see [Common Error Types](CommonErrors.md).

 ** ExecutionDoesNotExist **   
The specified execution does not exist.  
HTTP Status Code: 400

 ** InvalidArn **   
The provided Amazon Resource Name (ARN) is not valid.  
HTTP Status Code: 400

 ** InvalidToken **   
The provided token is not valid.  
HTTP Status Code: 400

 ** KmsAccessDeniedException **   
Either your Amazon KMS key policy or API caller does not have the required permissions.  
HTTP Status Code: 400

 ** KmsInvalidStateException **   
The Amazon KMS key is not in valid state, for example: Disabled or Deleted.    
 ** kmsKeyState **   
Current status of the Amazon KMS; key. For example: `DISABLED`, `PENDING_DELETION`, `PENDING_IMPORT`, `UNAVAILABLE`, `CREATING`.
HTTP Status Code: 400

 ** KmsThrottlingException **   
Received when Amazon KMS returns `ThrottlingException` for a Amazon KMS call that Step Functions makes on behalf of the caller.  
HTTP Status Code: 400

## Examples
<a name="API_GetExecutionHistory_Examples"></a>

### HelloWorld Execution History
<a name="API_GetExecutionHistory_Example_1"></a>

The following shows example output from `GetExecutionHistory` for a simple `HelloWorld` state machine, comprised of a single `Pass` state.

#### Sample Response
<a name="API_GetExecutionHistory_Example_1_Response"></a>

```
{
    "events": [
        {
            "timestamp": 1525283875.58,
            "executionStartedEventDetails": {
                "input": "{}",
                "inputDetails": {
                    "truncated": false
                },
                "roleArn": "arn:aws:iam::123456789123:role/service-role/StatesExecutionRole-us-east-1"
            },
            "type": "ExecutionStarted",
            "id": 1,
            "previousEventId": 0
        },
        {
            "timestamp": 1525283875.612,
            "type": "PassStateEntered",
            "id": 2,
            "stateEnteredEventDetails": {
                "input": "{}",
                "inputDetails": {
                    "truncated": false
                },
                "name": "HelloWorld"
            },
            "previousEventId": 0
        },
        {
            "timestamp": 1525283875.612,
            "stateExitedEventDetails": {
                "output": "\"Hello World!\"",
                "outputDetails": {
                    "truncated": false
                },
                "name": "HelloWorld"
            },
            "type": "PassStateExited",
            "id": 3,
            "previousEventId": 2
        },
        {
            "executionSucceededEventDetails": {
                "output": "\"Hello World!\"",
                "outputDetails": {
                    "truncated": false
                }
            },
            "timestamp": 1525283875.612,
            "type": "ExecutionSucceeded",
            "id": 4,
            "previousEventId": 3
        }
    ]
}
```

## See Also
<a name="API_GetExecutionHistory_SeeAlso"></a>

For more information about using this API in one of the language-specific Amazon SDKs, see the following:
+  [Amazon Command Line Interface V2](https://docs.amazonaws.cn/goto/cli2/states-2016-11-23/GetExecutionHistory) 
+  [Amazon SDK for .NET V4](https://docs.amazonaws.cn/goto/DotNetSDKV4/states-2016-11-23/GetExecutionHistory) 
+  [Amazon SDK for C\$1\$1](https://docs.amazonaws.cn/goto/SdkForCpp/states-2016-11-23/GetExecutionHistory) 
+  [Amazon SDK for Go v2](https://docs.amazonaws.cn/goto/SdkForGoV2/states-2016-11-23/GetExecutionHistory) 
+  [Amazon SDK for Java V2](https://docs.amazonaws.cn/goto/SdkForJavaV2/states-2016-11-23/GetExecutionHistory) 
+  [Amazon SDK for JavaScript V3](https://docs.amazonaws.cn/goto/SdkForJavaScriptV3/states-2016-11-23/GetExecutionHistory) 
+  [Amazon SDK for Kotlin](https://docs.amazonaws.cn/goto/SdkForKotlin/states-2016-11-23/GetExecutionHistory) 
+  [Amazon SDK for PHP V3](https://docs.amazonaws.cn/goto/SdkForPHPV3/states-2016-11-23/GetExecutionHistory) 
+  [Amazon SDK for Python](https://docs.amazonaws.cn/goto/boto3/states-2016-11-23/GetExecutionHistory) 
+  [Amazon SDK for Ruby V3](https://docs.amazonaws.cn/goto/SdkForRubyV3/states-2016-11-23/GetExecutionHistory) 