

# RecordActivityTaskHeartbeat
<a name="API_RecordActivityTaskHeartbeat"></a>

Used by activity workers to report to the service that the [ActivityTask](API_ActivityTask.md) represented by the specified `taskToken` is still making progress. The worker can also specify details of the progress, for example percent complete, using the `details` parameter. This action can also be used by the worker as a mechanism to check if cancellation is being requested for the activity task. If a cancellation is being attempted for the specified task, then the boolean `cancelRequested` flag returned by the service is set to `true`.

This action resets the `taskHeartbeatTimeout` clock. The `taskHeartbeatTimeout` is specified in [RegisterActivityType](API_RegisterActivityType.md).

This action doesn't in itself create an event in the workflow execution history. However, if the task times out, the workflow execution history contains a `ActivityTaskTimedOut` event that contains the information from the last heartbeat generated by the activity worker.

**Note**  
The `taskStartToCloseTimeout` of an activity type is the maximum duration of an activity task, regardless of the number of [RecordActivityTaskHeartbeat](#API_RecordActivityTaskHeartbeat) requests received. The `taskStartToCloseTimeout` is also specified in [RegisterActivityType](API_RegisterActivityType.md).

**Note**  
This operation is only useful for long-lived activities to report liveliness of the task and to determine if a cancellation is being attempted.

**Important**  
If the `cancelRequested` flag returns `true`, a cancellation is being attempted. If the worker can cancel the activity, it should respond with [RespondActivityTaskCanceled](API_RespondActivityTaskCanceled.md). Otherwise, it should ignore the cancellation request.

 **Access Control** 

You can use IAM policies to control this action's access to Amazon SWF resources as follows:
+ Use a `Resource` element with the domain name to limit the action to only specified domains.
+ Use an `Action` element to allow or deny permission to call this action.
+ You cannot use an IAM policy to constrain this action's parameters.

If the caller doesn't have sufficient permissions to invoke the action, or the parameter values fall outside the specified constraints, the action fails. The associated event attribute's `cause` parameter is set to `OPERATION_NOT_PERMITTED`. For details and example IAM policies, see [Using IAM to Manage Access to Amazon SWF Workflows](https://docs.aws.amazon.com/amazonswf/latest/developerguide/swf-dev-iam.html) in the *Amazon SWF Developer Guide*.

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

```
{
   "details": "string",
   "taskToken": "string"
}
```

## Request Parameters
<a name="API_RecordActivityTaskHeartbeat_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.

 ** [details](#API_RecordActivityTaskHeartbeat_RequestSyntax) **   <a name="SWF-RecordActivityTaskHeartbeat-request-details"></a>
If specified, contains details about the progress of the task.  
Type: String  
Length Constraints: Maximum length of 2048.  
Required: No

 ** [taskToken](#API_RecordActivityTaskHeartbeat_RequestSyntax) **   <a name="SWF-RecordActivityTaskHeartbeat-request-taskToken"></a>
The `taskToken` of the [ActivityTask](API_ActivityTask.md).  
 `taskToken` is generated by the service and should be treated as an opaque value. If the task is passed to another process, its `taskToken` must also be passed. This enables it to provide its progress and respond with results. 
Type: String  
Length Constraints: Minimum length of 1. Maximum length of 1024.  
Required: Yes

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

```
{
   "cancelRequested": boolean
}
```

## Response Elements
<a name="API_RecordActivityTaskHeartbeat_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.

 ** [cancelRequested](#API_RecordActivityTaskHeartbeat_ResponseSyntax) **   <a name="SWF-RecordActivityTaskHeartbeat-response-cancelRequested"></a>
Set to `true` if cancellation of the task is requested.  
Type: Boolean

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

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

 ** OperationNotPermittedFault **   
Returned when the caller doesn't have sufficient permissions to invoke the action.    
 ** message **   
A description that may help with diagnosing the cause of the fault.
HTTP Status Code: 400

 ** UnknownResourceFault **   
Returned when the named resource cannot be found with in the scope of this operation (region or domain). This could happen if the named resource was never created or is no longer available for this operation.    
 ** message **   
A description that may help with diagnosing the cause of the fault.
HTTP Status Code: 400

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

### RecordActivityTaskHeartbeat Example
<a name="API_RecordActivityTaskHeartbeat_Example_1"></a>

This example illustrates one usage of RecordActivityTaskHeartbeat.

#### Sample Request
<a name="API_RecordActivityTaskHeartbeat_Example_1_Request"></a>

```
POST / HTTP/1.1
Host: swf.us-east-1.amazonaws.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.25) Gecko/20111212 Firefox/3.6.25 ( .NET CLR 3.5.30729; .NET4.0E)
Accept: application/json, text/javascript, */*
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
Content-Type: application/x-amz-json-1.0
X-Requested-With: XMLHttpRequest
X-Amz-Date: Mon, 16 Jan 2012 03:55:06 GMT
X-Amz-Target: SimpleWorkflowService.RecordActivityTaskHeartbeat
Content-Encoding: amz-1.0
X-Amzn-Authorization: AWS3 AWSAccessKeyId=AKIAIOSFODNN7EXAMPLE,Algorithm=HmacSHA256,SignedHeaders=Host;X-Amz-Date;X-Amz-Target;Content-Encoding,Signature=DEA8rw5TqtpqCeTljl7eotZkuWTgmGZ1PWyDNZPehT0=
Referer: http://swf.us-east-1.amazonaws.com/explorer/index.html
Content-Length: 623
Pragma: no-cache
Cache-Control: no-cache

{"taskToken": "AAAAKgAAAAEAAAAAAAAAAX9p3pcp3857oLXFUuwdxRU5/zmn9f40XaMF7VohAH4jOtjXpZu7GdOzEi0b3cWYHbG5b5dpdcTXHUDPVMHXiUxCgr+Nc/wUW9016W4YxJGs/jmxzPln8qLftU+SW135Q0UuKp5XRGoRTJp3tbHn2pY1vC8gDB/K69J6q668U1pd4Cd9o43//lGgOIjN0/Ihg+DO+83HNcOuVEQMM28kNMXf7yePh31M4dMKJwQaQZG13huJXDwzJOoZQz+XFuqFly+lPnCE4XvsnhfAvTsh50EtNDEtQzPCFJoUeld9g64V/FS/39PHL3M93PBUuroPyHuCwHsNC6fZ7gM/XOKmW4kKnXPoQweEUkFV/J6E6+M1reBO7nJADTrLSnajg6MY/viWsEYmMw/DS5FlquFaDIhFkLhWUWN+V2KqiKS23GYwpzgZ7fgcWHQF2NLEY3zrjam4LW/UW5VLCyM3FpVD3erCTi9IvUgslPzyVGuWNAoTmgJEWvimgwiHxJMxxc9JBDR390iMmImxVl3eeSDUWx8reQltiviadPDjyRmVhYP8",
"details": "starting task"}
```

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

```
HTTP/1.1 200 OK
Content-Length: 25
Content-Type: application/json
x-amzn-RequestId: e08622cd-3ff5-11e1-9b11-7182192d0b57

{"cancelRequested":false}
```

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

For more information about using this API in one of the language-specific AWS SDKs, see the following:
+  [AWS Command Line Interface V2](https://docs.aws.amazon.com/goto/cli2/swf-2012-01-25/RecordActivityTaskHeartbeat) 
+  [AWS SDK for .NET V4](https://docs.aws.amazon.com/goto/DotNetSDKV4/swf-2012-01-25/RecordActivityTaskHeartbeat) 
+  [AWS SDK for C\$1\$1](https://docs.aws.amazon.com/goto/SdkForCpp/swf-2012-01-25/RecordActivityTaskHeartbeat) 
+  [AWS SDK for Go v2](https://docs.aws.amazon.com/goto/SdkForGoV2/swf-2012-01-25/RecordActivityTaskHeartbeat) 
+  [AWS SDK for Java V2](https://docs.aws.amazon.com/goto/SdkForJavaV2/swf-2012-01-25/RecordActivityTaskHeartbeat) 
+  [AWS SDK for JavaScript V3](https://docs.aws.amazon.com/goto/SdkForJavaScriptV3/swf-2012-01-25/RecordActivityTaskHeartbeat) 
+  [AWS SDK for Kotlin](https://docs.aws.amazon.com/goto/SdkForKotlin/swf-2012-01-25/RecordActivityTaskHeartbeat) 
+  [AWS SDK for PHP V3](https://docs.aws.amazon.com/goto/SdkForPHPV3/swf-2012-01-25/RecordActivityTaskHeartbeat) 
+  [AWS SDK for Python](https://docs.aws.amazon.com/goto/boto3/swf-2012-01-25/RecordActivityTaskHeartbeat) 
+  [AWS SDK for Ruby V3](https://docs.aws.amazon.com/goto/SdkForRubyV3/swf-2012-01-25/RecordActivityTaskHeartbeat) 