> For the complete documentation index, see [llms.txt](https://docs.mailtrap.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.mailtrap.io/developers/email-marketing/email-campaigns/reset-an-email-campaign-to-draft.md).

# Reset an email campaign to draft

Resets a campaign back to the `draft` state. Allowed only from the `scheduled` state; resetting from any other state (e.g. a sending or terminal state) returns `422`.

```json
{"openapi":"3.1.0","info":{"title":"Email Campaigns","version":"2.0.0"},"tags":[{"name":"Email Campaigns","description":"Manage email campaigns"}],"servers":[{"description":"Mailtrap API","url":"https://mailtrap.io"}],"security":[{"HeaderAuth":[]},{"BearerAuth":[]}],"components":{"securitySchemes":{"HeaderAuth":{"type":"apiKey","description":"Pass the API token in the Api-Token header","in":"header","name":"Api-Token"},"BearerAuth":{"type":"http","description":"Pass the API token as a Bearer token in the Authorization header","scheme":"bearer"}},"parameters":{"email_campaign_id":{"name":"email_campaign_id","description":"Unique identifier of the email campaign","in":"path","required":true,"schema":{"type":"integer","format":"int64","minimum":1}}},"responses":{"EmailCampaignResponse":{"description":"A single email campaign.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/EmailCampaign"}}}}}},"UNAUTHENTICATED":{"description":"Authentication failed — missing or invalid API token.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnauthenticatedResponse"}}}},"PERMISSION_DENIED":{"description":"The API token does not have permission to access this resource.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PermissionDeniedResponse"}}}},"NOT_FOUND":{"description":"The requested email campaign was not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/NotFoundResponse"}}}},"ACTION_VALIDATION_ERROR":{"description":"The lifecycle action was rejected — the campaign was in a state that does not allow the\naction, the `datetime` was invalid, or sending validation failed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ActionValidationErrorResponse"}}}},"RATE_LIMITED":{"description":"Too many requests. The public API is rate limited to 150 requests per 10 seconds per\nAPI token. Retry after the window resets (see the `x-ratelimit-reset` header).","headers":{},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RateLimitedResponse"}}}}},"schemas":{"EmailCampaign":{"type":"object","properties":{"id":{"type":"integer","format":"int64"},"domain_id":{"type":"integer","format":"int64","description":"ID of the sending domain used for the campaign, as returned by the Sending Domains endpoints."},"domain_name":{"type":"string"},"name":{"type":"string"},"from_local_part":{"type":"string"},"from_display_name":{"type":"string"},"reply_to":{"$ref":"#/components/schemas/ReplyTo"},"current_state":{"type":"string","description":"Current state of the campaign in its lifecycle.","enum":["draft","scheduled","started","queued","paused","terminating","under_review","finished","failed","failed_immediately"]},"current_state_metadata":{"type":"object","description":"Metadata about the most recent state transition. Which keys are present depends on the state.","properties":{"reason":{"type":"string"},"error":{"type":"string","description":"Last error message recorded for a failed campaign."},"errors":{"type":"array","description":"Per-recipient errors recorded when sending failed.","items":{"type":"object","properties":{"message":{"type":"string"},"rcpt_index":{"type":"integer"}}}},"scheduled_at":{"type":"string","format":"date-time","description":"When the campaign is scheduled to send (ISO 8601). Present in the `scheduled` state."}}},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"},"last_started_at":{"type":["string","null"],"format":"date-time"},"last_started_at_date":{"type":"string","format":"date","description":"Date the campaign was last started. Present only when the campaign has been started."},"recipient_total_count":{"type":["integer","null"],"description":"Total number of recipients targeted by the campaign. `null` until the audience is resolved."},"contact_list_ids":{"type":"array","description":"IDs of the contact lists included in the campaign's audience.","items":{"type":"integer","format":"int64"}},"contact_segment_ids":{"type":"array","description":"IDs of the contact segments included in the campaign's audience.","items":{"type":"integer","format":"int64"}},"delivery_mode":{"type":"string","description":"How the campaign is delivered. `rapid` sends as fast as possible; `gradual` throttles\nsending to `delivery_options.emails_per_hour`.","enum":["rapid","gradual"]},"delivery_options":{"type":"object","description":"Delivery throttling options. Applies when `delivery_mode` is `gradual`.","properties":{"emails_per_hour":{"type":["integer","null"]}}},"template":{"type":"object","description":"The campaign's template. `body_html` and `body_text` are returned only on\nsingle-campaign responses (create, update, get-by-ID); the list endpoint omits them to\nkeep the payload small.","properties":{"id":{"type":"integer","format":"int64"},"subject":{"type":"string"},"merge_tags":{"type":"array","items":{"type":"string"}},"body_html":{"type":["string","null"],"description":"HTML body (the design). Returned only on single-campaign responses."},"body_text":{"type":["string","null"],"description":"Plain-text body. Returned only on single-campaign responses."}}}}},"ReplyTo":{"type":"object","description":"Reply-To address parts.","properties":{"display_name":{"type":"string"},"local_part":{"type":"string"},"domain":{"type":"string"}}},"UnauthenticatedResponse":{"type":"object","properties":{"error":{"type":"string"}}},"PermissionDeniedResponse":{"type":"object","properties":{"errors":{"type":"string"}}},"NotFoundResponse":{"type":"object","properties":{"error":{"type":"string"}}},"ActionValidationErrorResponse":{"type":"object","description":"Validation error returned by the lifecycle action endpoints. `errors` is either a single\nmessage (an invalid state transition or an invalid `datetime`) or a list of messages\n(sending-validation failures).","properties":{"errors":{"oneOf":[{"type":"string"},{"type":"array","items":{"type":"string"}}]}}},"RateLimitedResponse":{"type":"object","properties":{"error":{"type":"string"}}}}},"paths":{"/api/email_campaigns/{email_campaign_id}/reset":{"post":{"operationId":"resetEmailCampaign","summary":"Reset an email campaign to draft","description":"Resets a campaign back to the `draft` state. Allowed only from the `scheduled` state;\nresetting from any other state (e.g. a sending or terminal state) returns `422`.","tags":["Email Campaigns"],"parameters":[{"$ref":"#/components/parameters/email_campaign_id"}],"responses":{"200":{"$ref":"#/components/responses/EmailCampaignResponse"},"401":{"$ref":"#/components/responses/UNAUTHENTICATED"},"403":{"$ref":"#/components/responses/PERMISSION_DENIED"},"404":{"$ref":"#/components/responses/NOT_FOUND"},"422":{"$ref":"#/components/responses/ACTION_VALIDATION_ERROR"},"429":{"$ref":"#/components/responses/RATE_LIMITED"}}}}}}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.mailtrap.io/developers/email-marketing/email-campaigns/reset-an-email-campaign-to-draft.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
