> For a complete page index, fetch https://developer.close.com/llms.txt

# Update an Email activity

PUT https://api.close.com/api/v1/activity/email/{id}/
Content-Type: application/json

This can be used to modify a draft or send it once the draft is complete.

When changing a draft's status to `scheduled` or `outbox`, the `sender` field is required if not already set on the email.

Reference: https://developer.close.com/api/resources/activities/emails/update

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: Close API
  version: 1.0.0
paths:
  /activity/email/{id}/:
    put:
      operationId: update
      summary: Update an Email activity
      description: >-
        This can be used to modify a draft or send it once the draft is
        complete.


        When changing a draft's status to `scheduled` or `outbox`, the `sender`
        field is required if not already set on the email.
      tags:
        - subpackage_activitiesEmails
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
        - name: Authorization
          in: header
          description: Use your API key as the username and leave the password empty.
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EmailActivity'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                description: Any type
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                description: Any type
        '404':
          description: Not found
          content:
            application/json:
              schema:
                description: Any type
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateEmailActivity'
servers:
  - url: https://api.close.com/api/v1
components:
  schemas:
    UpdateEmailActivityAttachmentsItems:
      type: object
      properties:
        content_id:
          type:
            - string
            - 'null'
        content_type:
          type:
            - string
            - 'null'
        filename:
          type: string
        inline_only:
          type: boolean
        size:
          type: integer
        url:
          type: string
          format: uri
      required:
        - filename
        - size
        - url
      title: UpdateEmailActivityAttachmentsItems
    UpdateEmailActivityOpensItems:
      type: object
      properties:
        opened_at:
          type: string
          format: date-time
      required:
        - opened_at
      title: UpdateEmailActivityOpensItems
    UpdateEmailActivityStatus:
      type: string
      enum:
        - inbox
        - draft
        - scheduled
        - outbox
        - sent
        - error
      title: UpdateEmailActivityStatus
    UpdateEmailActivity:
      type: object
      properties:
        account_id:
          type:
            - string
            - 'null'
        activity_at:
          type:
            - string
            - 'null'
          format: date-time
        attachments:
          type:
            - array
            - 'null'
          items:
            $ref: '#/components/schemas/UpdateEmailActivityAttachmentsItems'
        bcc:
          type:
            - array
            - 'null'
          items:
            type: string
        body_html:
          type:
            - string
            - 'null'
        body_text:
          type:
            - string
            - 'null'
        cc:
          type:
            - array
            - 'null'
          items:
            type: string
        contact_id:
          type:
            - string
            - 'null'
        followup_date:
          type:
            - string
            - 'null'
          format: date-time
        followup_sequence_add_cc_bcc:
          type:
            - boolean
            - 'null'
        followup_sequence_delay:
          type:
            - integer
            - 'null'
        followup_sequence_id:
          type:
            - string
            - 'null'
        in_reply_to_id:
          type:
            - string
            - 'null'
        opens:
          type:
            - array
            - 'null'
          items:
            $ref: '#/components/schemas/UpdateEmailActivityOpensItems'
        sender:
          type:
            - string
            - 'null'
          format: email
        status:
          $ref: '#/components/schemas/UpdateEmailActivityStatus'
        subject:
          type:
            - string
            - 'null'
        template_id:
          type:
            - string
            - 'null'
        to:
          type:
            - array
            - 'null'
          items:
            type: string
        user_id:
          type:
            - string
            - 'null'
      title: UpdateEmailActivity
    Attachment:
      type: object
      properties:
        content_type:
          type:
            - string
            - 'null'
        filename:
          type:
            - string
            - 'null'
        size:
          type:
            - integer
            - 'null'
        thumbnail_url:
          type:
            - string
            - 'null'
        url:
          type: string
      required:
        - content_type
        - filename
        - size
        - url
      title: Attachment
    CommunicationDirection:
      type: string
      enum:
        - incoming
        - outgoing
      description: >-
        Direction of communication. Outgoing means the communication flowing
        from the user to the lead/contact. Inbound means the opposite.
      title: CommunicationDirection
    MessageStatus:
      type: string
      enum:
        - inbox
        - draft
        - scheduled
        - outbox
        - sent
        - error
      description: Status of a message, such as Email or SMS.
      title: MessageStatus
    EmailActivity:
      type: object
      properties:
        _type:
          type: string
        activity_at:
          type:
            - string
            - 'null'
          format: date-time
        agent_action_reason:
          type:
            - string
            - 'null'
        agent_config_id:
          type:
            - string
            - 'null'
        attachments:
          type:
            - array
            - 'null'
          items:
            $ref: '#/components/schemas/Attachment'
        bcc:
          type: array
          items:
            type: string
        body_html:
          type:
            - string
            - 'null'
        body_preview:
          type:
            - string
            - 'null'
        body_text:
          type:
            - string
            - 'null'
        bulk_email_action_id:
          type:
            - string
            - 'null'
        cc:
          type: array
          items:
            type: string
        contact_id:
          type:
            - string
            - 'null'
        created_by:
          type:
            - string
            - 'null'
        created_by_name:
          type:
            - string
            - 'null'
        date_created:
          type: string
          format: date-time
        date_scheduled:
          type:
            - string
            - 'null'
          format: date-time
        date_sent:
          type:
            - string
            - 'null'
          format: date-time
        date_updated:
          type: string
          format: date-time
        direction:
          oneOf:
            - $ref: '#/components/schemas/CommunicationDirection'
            - type: 'null'
        email_account_id:
          type:
            - string
            - 'null'
        envelope:
          type:
            - object
            - 'null'
          additionalProperties:
            description: Any type
        followup_sequence_add_cc_bcc:
          type: boolean
        followup_sequence_delay:
          type:
            - integer
            - 'null'
        followup_sequence_id:
          type:
            - string
            - 'null'
        has_reply:
          type: boolean
        id:
          type: string
        in_reply_to_id:
          type:
            - string
            - 'null'
        lead_id:
          type:
            - string
            - 'null'
        message_ids:
          type: array
          items:
            type: string
        need_smtp_credentials:
          type: boolean
        opens:
          type:
            - array
            - 'null'
          items:
            type: object
            additionalProperties:
              type: string
        opens_summary:
          type:
            - string
            - 'null'
        organization_id:
          type: string
        references:
          type: array
          items:
            type: string
        send_as_id:
          type:
            - string
            - 'null'
        send_attempts:
          type:
            - array
            - 'null'
          items:
            type: object
            additionalProperties:
              type: string
        sender:
          type:
            - string
            - 'null'
        sequence_id:
          type:
            - string
            - 'null'
        sequence_name:
          type:
            - string
            - 'null'
        sequence_subscription_id:
          type:
            - string
            - 'null'
        status:
          $ref: '#/components/schemas/MessageStatus'
        subject:
          type:
            - string
            - 'null'
        template_id:
          type:
            - string
            - 'null'
        template_name:
          type:
            - string
            - 'null'
        thread_id:
          type:
            - string
            - 'null'
        to:
          type: array
          items:
            type: string
        updated_by:
          type:
            - string
            - 'null'
        updated_by_name:
          type:
            - string
            - 'null'
        user_id:
          type:
            - string
            - 'null'
        user_name:
          type:
            - string
            - 'null'
        users:
          type: array
          items:
            type: string
      required:
        - _type
        - activity_at
        - bcc
        - body_html
        - body_text
        - bulk_email_action_id
        - cc
        - contact_id
        - created_by
        - date_created
        - date_scheduled
        - date_sent
        - date_updated
        - direction
        - followup_sequence_add_cc_bcc
        - followup_sequence_delay
        - has_reply
        - id
        - in_reply_to_id
        - lead_id
        - message_ids
        - need_smtp_credentials
        - opens_summary
        - organization_id
        - references
        - send_as_id
        - sender
        - status
        - subject
        - template_id
        - thread_id
        - to
        - updated_by
        - user_id
        - users
      title: EmailActivity
  securitySchemes:
    ApiKeyAuth:
      type: http
      scheme: basic
      description: Use your API key as the username and leave the password empty.
    OAuth2:
      type: http
      scheme: bearer

```

## SDK Code Examples

```python activities.emails_update_example
import requests

url = "https://api.close.com/api/v1/activity/email/id/"

payload = { "subject": "Updated subject!" }
headers = {
    "Content-Type": "application/json"
}

response = requests.put(url, json=payload, headers=headers, auth=("<CLOSE_API_KEY>", ""))

print(response.json())
```

```javascript activities.emails_update_example
const url = 'https://api.close.com/api/v1/activity/email/id/';
const credentials = btoa("<CLOSE_API_KEY>:");

const options = {
  method: 'PUT',
  headers: {Authorization: `Basic ${credentials}`, 'Content-Type': 'application/json'},
  body: '{"subject":"Updated subject!"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go activities.emails_update_example
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.close.com/api/v1/activity/email/id/"

	payload := strings.NewReader("{\n  \"subject\": \"Updated subject!\"\n}")

	req, _ := http.NewRequest("PUT", url, payload)

	req.SetBasicAuth("<CLOSE_API_KEY>", "")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby activities.emails_update_example
require 'uri'
require 'net/http'

url = URI("https://api.close.com/api/v1/activity/email/id/")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Put.new(url)
request.basic_auth("<CLOSE_API_KEY>", "")
request["Content-Type"] = 'application/json'
request.body = "{\n  \"subject\": \"Updated subject!\"\n}"

response = http.request(request)
puts response.read_body
```

```java activities.emails_update_example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.put("https://api.close.com/api/v1/activity/email/id/")
  .basicAuth("<CLOSE_API_KEY>", "")
  .header("Content-Type", "application/json")
  .body("{\n  \"subject\": \"Updated subject!\"\n}")
  .asString();
```

```php activities.emails_update_example
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('PUT', 'https://api.close.com/api/v1/activity/email/id/', [
  'body' => '{
  "subject": "Updated subject!"
}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
    'auth' => ['<CLOSE_API_KEY>', ''],
]);

echo $response->getBody();
```

```csharp activities.emails_update_example
using RestSharp;
using RestSharp.Authenticators;

var client = new RestClient("https://api.close.com/api/v1/activity/email/id/");
client.Authenticator = new HttpBasicAuthenticator("<CLOSE_API_KEY>", "");
var request = new RestRequest(Method.PUT);

request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"subject\": \"Updated subject!\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```