# Sandboxes

Manage Sandboxes for email testing. Capture and inspect emails without delivering them to real recipients. This is ideal for development, staging, and QA environments.

#### Get your Sandbox ID

To use the Sandbox API, you need a Sandbox ID. You can get it in one of the following ways.

**Option 1: From the sandbox URL**

1. Open your Sandbox in Mailtrap.
2. Copy the ID from the sandbox URL.

Example:

* URL: <https://mailtrap.io/sandboxes/2564102/settings>
* Sandbox ID: 2564102

**Option 2: Via the API**

Use the `Get a list of sandboxes` endpoint to retrieve all Sandboxes in your account.

## Get a list of sandboxes

> Get a list of sandboxes.

```json
{"openapi":"3.1.0","info":{"title":"Email Sandbox","version":"2.0.0"},"tags":[{"name":"Sandboxes","description":"Manage Sandboxes for email testing. Capture and inspect emails without delivering them to real recipients. This is ideal for development, staging, and QA environments.\n\n### Get your Sandbox ID\n\nTo use the Sandbox API, you need a Sandbox ID. You can get it in one of the following ways.\n\n#### Option 1: From the sandbox URL\n\n1. Open your Sandbox in Mailtrap.\n2. Copy the ID from the sandbox URL.\n\nExample:\n  - URL: https://mailtrap.io/sandboxes/2564102/settings\n  - Sandbox ID: 2564102\n\n#### Option 2: Via the API\n\nUse the `Get a list of sandboxes` endpoint to retrieve all Sandboxes in your account.\n"}],"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","in":"header","name":"Api-Token"},"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT"}},"responses":{"SandboxesResponse":{"description":"Returns the list of sandboxes in the account to which the API token has access.\n- **permissions** returns the permissions of the token for the sandbox.","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/TestingSandbox"}}}}},"UNAUTHENTICATED":{"description":"Returns unauthorized error message. Check your credentials.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnauthenticatedResponse"}}}},"PERMISSION_DENIED":{"description":"Returns forbidden error message. Check your permissions.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PermissionsDeniedResponse"}}}}},"schemas":{"TestingSandbox":{"title":"Testing Sandbox","type":"object","properties":{"id":{"type":"integer"},"name":{"type":"string"},"username":{"type":"string"},"password":{"type":"string","nullable":true,"description":"Password is only available if you have admin permissions for the sandbox."},"max_size":{"type":"integer"},"status":{"type":"string","enum":["active","inactive","pending"]},"email_username":{"type":"string"},"email_username_enabled":{"type":"boolean"},"sent_messages_count":{"type":"integer"},"forwarded_messages_count":{"type":"integer"},"used":{"type":"boolean"},"forward_from_email_address":{"type":"string"},"project_id":{"type":"integer"},"domain":{"type":"string"},"pop3_domain":{"type":"string"},"email_domain":{"type":"string"},"api_domain":{"type":"string"},"emails_count":{"type":"integer"},"emails_unread_count":{"type":"integer"},"last_message_sent_at":{"nullable":true,"type":"string"},"smtp_ports":{"type":"array","items":{"type":"integer"}},"pop3_ports":{"type":"array","items":{"type":"integer"}},"max_message_size":{"type":"integer"},"permissions":{"type":"object","properties":{"can_read":{"type":"boolean"},"can_update":{"type":"boolean"},"can_destroy":{"type":"boolean"},"can_leave":{"type":"boolean"}}}}},"UnauthenticatedResponse":{"title":"UnauthenticatedResponse","type":"object","properties":{"error":{"type":"string","description":"Error message"}}},"PermissionsDeniedResponse":{"title":"PermissionsDeniedResponse","type":"object","properties":{"errors":{"type":"string","description":"Error message"}}}}},"paths":{"/api/sandboxes":{"get":{"summary":"Get a list of sandboxes","description":"Get a list of sandboxes.","tags":["Sandboxes"],"responses":{"200":{"$ref":"#/components/responses/SandboxesResponse"},"401":{"$ref":"#/components/responses/UNAUTHENTICATED"},"403":{"$ref":"#/components/responses/PERMISSION_DENIED"}},"operationId":"getSandboxes"}}}}
```

## Create a sandbox

> Create a sandbox in a project.

```json
{"openapi":"3.1.0","info":{"title":"Email Sandbox","version":"2.0.0"},"tags":[{"name":"Sandboxes","description":"Manage Sandboxes for email testing. Capture and inspect emails without delivering them to real recipients. This is ideal for development, staging, and QA environments.\n\n### Get your Sandbox ID\n\nTo use the Sandbox API, you need a Sandbox ID. You can get it in one of the following ways.\n\n#### Option 1: From the sandbox URL\n\n1. Open your Sandbox in Mailtrap.\n2. Copy the ID from the sandbox URL.\n\nExample:\n  - URL: https://mailtrap.io/sandboxes/2564102/settings\n  - Sandbox ID: 2564102\n\n#### Option 2: Via the API\n\nUse the `Get a list of sandboxes` endpoint to retrieve all Sandboxes in your account.\n"}],"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","in":"header","name":"Api-Token"},"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT"}},"responses":{"SandboxResponse":{"description":"Returns attributes of the sandbox.\n- **permissions** returns the permissions of the token for the sandbox.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TestingSandbox"}}}},"UNAUTHENTICATED":{"description":"Returns unauthorized error message. Check your credentials.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnauthenticatedResponse"}}}},"PERMISSION_DENIED":{"description":"Returns forbidden error message. Check your permissions.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PermissionsDeniedResponse"}}}},"NOT_FOUND":{"description":"Returns not found error message","content":{"application/json":{"schema":{"$ref":"#/components/schemas/NotFoundResponse"}}}}},"schemas":{"TestingSandbox":{"title":"Testing Sandbox","type":"object","properties":{"id":{"type":"integer"},"name":{"type":"string"},"username":{"type":"string"},"password":{"type":"string","nullable":true,"description":"Password is only available if you have admin permissions for the sandbox."},"max_size":{"type":"integer"},"status":{"type":"string","enum":["active","inactive","pending"]},"email_username":{"type":"string"},"email_username_enabled":{"type":"boolean"},"sent_messages_count":{"type":"integer"},"forwarded_messages_count":{"type":"integer"},"used":{"type":"boolean"},"forward_from_email_address":{"type":"string"},"project_id":{"type":"integer"},"domain":{"type":"string"},"pop3_domain":{"type":"string"},"email_domain":{"type":"string"},"api_domain":{"type":"string"},"emails_count":{"type":"integer"},"emails_unread_count":{"type":"integer"},"last_message_sent_at":{"nullable":true,"type":"string"},"smtp_ports":{"type":"array","items":{"type":"integer"}},"pop3_ports":{"type":"array","items":{"type":"integer"}},"max_message_size":{"type":"integer"},"permissions":{"type":"object","properties":{"can_read":{"type":"boolean"},"can_update":{"type":"boolean"},"can_destroy":{"type":"boolean"},"can_leave":{"type":"boolean"}}}}},"UnauthenticatedResponse":{"title":"UnauthenticatedResponse","type":"object","properties":{"error":{"type":"string","description":"Error message"}}},"PermissionsDeniedResponse":{"title":"PermissionsDeniedResponse","type":"object","properties":{"errors":{"type":"string","description":"Error message"}}},"NotFoundResponse":{"title":"NotFoundResponse","type":"object","properties":{"error":{"type":"string","description":"Error message"}}}}},"paths":{"/api/projects/{project_id}/sandboxes":{"post":{"summary":"Create a sandbox","description":"Create a sandbox in a project.","tags":["Sandboxes"],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"sandbox":{"type":"object","properties":{"name":{"type":"string"}}}}}}}},"responses":{"200":{"$ref":"#/components/responses/SandboxResponse"},"401":{"$ref":"#/components/responses/UNAUTHENTICATED"},"403":{"$ref":"#/components/responses/PERMISSION_DENIED"},"404":{"$ref":"#/components/responses/NOT_FOUND"}},"operationId":"createSandbox"}}}}
```

## Get sandbox attributes

> Get sandbox attributes by sandbox id. See the list of attributes in the example

```json
{"openapi":"3.1.0","info":{"title":"Email Sandbox","version":"2.0.0"},"tags":[{"name":"Sandboxes","description":"Manage Sandboxes for email testing. Capture and inspect emails without delivering them to real recipients. This is ideal for development, staging, and QA environments.\n\n### Get your Sandbox ID\n\nTo use the Sandbox API, you need a Sandbox ID. You can get it in one of the following ways.\n\n#### Option 1: From the sandbox URL\n\n1. Open your Sandbox in Mailtrap.\n2. Copy the ID from the sandbox URL.\n\nExample:\n  - URL: https://mailtrap.io/sandboxes/2564102/settings\n  - Sandbox ID: 2564102\n\n#### Option 2: Via the API\n\nUse the `Get a list of sandboxes` endpoint to retrieve all Sandboxes in your account.\n"}],"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","in":"header","name":"Api-Token"},"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT"}},"responses":{"SandboxResponse":{"description":"Returns attributes of the sandbox.\n- **permissions** returns the permissions of the token for the sandbox.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TestingSandbox"}}}},"UNAUTHENTICATED":{"description":"Returns unauthorized error message. Check your credentials.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnauthenticatedResponse"}}}},"PERMISSION_DENIED":{"description":"Returns forbidden error message. Check your permissions.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PermissionsDeniedResponse"}}}},"NOT_FOUND":{"description":"Returns not found error message","content":{"application/json":{"schema":{"$ref":"#/components/schemas/NotFoundResponse"}}}}},"schemas":{"TestingSandbox":{"title":"Testing Sandbox","type":"object","properties":{"id":{"type":"integer"},"name":{"type":"string"},"username":{"type":"string"},"password":{"type":"string","nullable":true,"description":"Password is only available if you have admin permissions for the sandbox."},"max_size":{"type":"integer"},"status":{"type":"string","enum":["active","inactive","pending"]},"email_username":{"type":"string"},"email_username_enabled":{"type":"boolean"},"sent_messages_count":{"type":"integer"},"forwarded_messages_count":{"type":"integer"},"used":{"type":"boolean"},"forward_from_email_address":{"type":"string"},"project_id":{"type":"integer"},"domain":{"type":"string"},"pop3_domain":{"type":"string"},"email_domain":{"type":"string"},"api_domain":{"type":"string"},"emails_count":{"type":"integer"},"emails_unread_count":{"type":"integer"},"last_message_sent_at":{"nullable":true,"type":"string"},"smtp_ports":{"type":"array","items":{"type":"integer"}},"pop3_ports":{"type":"array","items":{"type":"integer"}},"max_message_size":{"type":"integer"},"permissions":{"type":"object","properties":{"can_read":{"type":"boolean"},"can_update":{"type":"boolean"},"can_destroy":{"type":"boolean"},"can_leave":{"type":"boolean"}}}}},"UnauthenticatedResponse":{"title":"UnauthenticatedResponse","type":"object","properties":{"error":{"type":"string","description":"Error message"}}},"PermissionsDeniedResponse":{"title":"PermissionsDeniedResponse","type":"object","properties":{"errors":{"type":"string","description":"Error message"}}},"NotFoundResponse":{"title":"NotFoundResponse","type":"object","properties":{"error":{"type":"string","description":"Error message"}}}}},"paths":{"/api/sandboxes/{sandbox_id}":{"get":{"summary":"Get sandbox attributes","description":"Get sandbox attributes by sandbox id. See the list of attributes in the example","tags":["Sandboxes"],"responses":{"200":{"$ref":"#/components/responses/SandboxResponse"},"401":{"$ref":"#/components/responses/UNAUTHENTICATED"},"403":{"$ref":"#/components/responses/PERMISSION_DENIED"},"404":{"$ref":"#/components/responses/NOT_FOUND"}},"operationId":"getSandboxAttributes"}}}}
```

## Delete a sandbox

> Delete a sandbox with all its emails.

```json
{"openapi":"3.1.0","info":{"title":"Email Sandbox","version":"2.0.0"},"tags":[{"name":"Sandboxes","description":"Manage Sandboxes for email testing. Capture and inspect emails without delivering them to real recipients. This is ideal for development, staging, and QA environments.\n\n### Get your Sandbox ID\n\nTo use the Sandbox API, you need a Sandbox ID. You can get it in one of the following ways.\n\n#### Option 1: From the sandbox URL\n\n1. Open your Sandbox in Mailtrap.\n2. Copy the ID from the sandbox URL.\n\nExample:\n  - URL: https://mailtrap.io/sandboxes/2564102/settings\n  - Sandbox ID: 2564102\n\n#### Option 2: Via the API\n\nUse the `Get a list of sandboxes` endpoint to retrieve all Sandboxes in your account.\n"}],"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","in":"header","name":"Api-Token"},"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT"}},"responses":{"SandboxResponse":{"description":"Returns attributes of the sandbox.\n- **permissions** returns the permissions of the token for the sandbox.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TestingSandbox"}}}},"UNAUTHENTICATED":{"description":"Returns unauthorized error message. Check your credentials.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnauthenticatedResponse"}}}},"PERMISSION_DENIED":{"description":"Returns forbidden error message. Check your permissions.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PermissionsDeniedResponse"}}}},"NOT_FOUND":{"description":"Returns not found error message","content":{"application/json":{"schema":{"$ref":"#/components/schemas/NotFoundResponse"}}}}},"schemas":{"TestingSandbox":{"title":"Testing Sandbox","type":"object","properties":{"id":{"type":"integer"},"name":{"type":"string"},"username":{"type":"string"},"password":{"type":"string","nullable":true,"description":"Password is only available if you have admin permissions for the sandbox."},"max_size":{"type":"integer"},"status":{"type":"string","enum":["active","inactive","pending"]},"email_username":{"type":"string"},"email_username_enabled":{"type":"boolean"},"sent_messages_count":{"type":"integer"},"forwarded_messages_count":{"type":"integer"},"used":{"type":"boolean"},"forward_from_email_address":{"type":"string"},"project_id":{"type":"integer"},"domain":{"type":"string"},"pop3_domain":{"type":"string"},"email_domain":{"type":"string"},"api_domain":{"type":"string"},"emails_count":{"type":"integer"},"emails_unread_count":{"type":"integer"},"last_message_sent_at":{"nullable":true,"type":"string"},"smtp_ports":{"type":"array","items":{"type":"integer"}},"pop3_ports":{"type":"array","items":{"type":"integer"}},"max_message_size":{"type":"integer"},"permissions":{"type":"object","properties":{"can_read":{"type":"boolean"},"can_update":{"type":"boolean"},"can_destroy":{"type":"boolean"},"can_leave":{"type":"boolean"}}}}},"UnauthenticatedResponse":{"title":"UnauthenticatedResponse","type":"object","properties":{"error":{"type":"string","description":"Error message"}}},"PermissionsDeniedResponse":{"title":"PermissionsDeniedResponse","type":"object","properties":{"errors":{"type":"string","description":"Error message"}}},"NotFoundResponse":{"title":"NotFoundResponse","type":"object","properties":{"error":{"type":"string","description":"Error message"}}}}},"paths":{"/api/sandboxes/{sandbox_id}":{"delete":{"summary":"Delete a sandbox","description":"Delete a sandbox with all its emails.","tags":["Sandboxes"],"responses":{"200":{"$ref":"#/components/responses/SandboxResponse"},"401":{"$ref":"#/components/responses/UNAUTHENTICATED"},"403":{"$ref":"#/components/responses/PERMISSION_DENIED"},"404":{"$ref":"#/components/responses/NOT_FOUND"}},"operationId":"deleteSandbox"}}}}
```

## Update a sandbox

> Update sandbox name, sandbox email username.

```json
{"openapi":"3.1.0","info":{"title":"Email Sandbox","version":"2.0.0"},"tags":[{"name":"Sandboxes","description":"Manage Sandboxes for email testing. Capture and inspect emails without delivering them to real recipients. This is ideal for development, staging, and QA environments.\n\n### Get your Sandbox ID\n\nTo use the Sandbox API, you need a Sandbox ID. You can get it in one of the following ways.\n\n#### Option 1: From the sandbox URL\n\n1. Open your Sandbox in Mailtrap.\n2. Copy the ID from the sandbox URL.\n\nExample:\n  - URL: https://mailtrap.io/sandboxes/2564102/settings\n  - Sandbox ID: 2564102\n\n#### Option 2: Via the API\n\nUse the `Get a list of sandboxes` endpoint to retrieve all Sandboxes in your account.\n"}],"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","in":"header","name":"Api-Token"},"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT"}},"responses":{"SandboxResponse":{"description":"Returns attributes of the sandbox.\n- **permissions** returns the permissions of the token for the sandbox.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TestingSandbox"}}}},"UNAUTHENTICATED":{"description":"Returns unauthorized error message. Check your credentials.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnauthenticatedResponse"}}}},"PERMISSION_DENIED":{"description":"Returns forbidden error message. Check your permissions.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PermissionsDeniedResponse"}}}},"NOT_FOUND":{"description":"Returns not found error message","content":{"application/json":{"schema":{"$ref":"#/components/schemas/NotFoundResponse"}}}}},"schemas":{"TestingSandbox":{"title":"Testing Sandbox","type":"object","properties":{"id":{"type":"integer"},"name":{"type":"string"},"username":{"type":"string"},"password":{"type":"string","nullable":true,"description":"Password is only available if you have admin permissions for the sandbox."},"max_size":{"type":"integer"},"status":{"type":"string","enum":["active","inactive","pending"]},"email_username":{"type":"string"},"email_username_enabled":{"type":"boolean"},"sent_messages_count":{"type":"integer"},"forwarded_messages_count":{"type":"integer"},"used":{"type":"boolean"},"forward_from_email_address":{"type":"string"},"project_id":{"type":"integer"},"domain":{"type":"string"},"pop3_domain":{"type":"string"},"email_domain":{"type":"string"},"api_domain":{"type":"string"},"emails_count":{"type":"integer"},"emails_unread_count":{"type":"integer"},"last_message_sent_at":{"nullable":true,"type":"string"},"smtp_ports":{"type":"array","items":{"type":"integer"}},"pop3_ports":{"type":"array","items":{"type":"integer"}},"max_message_size":{"type":"integer"},"permissions":{"type":"object","properties":{"can_read":{"type":"boolean"},"can_update":{"type":"boolean"},"can_destroy":{"type":"boolean"},"can_leave":{"type":"boolean"}}}}},"UnauthenticatedResponse":{"title":"UnauthenticatedResponse","type":"object","properties":{"error":{"type":"string","description":"Error message"}}},"PermissionsDeniedResponse":{"title":"PermissionsDeniedResponse","type":"object","properties":{"errors":{"type":"string","description":"Error message"}}},"NotFoundResponse":{"title":"NotFoundResponse","type":"object","properties":{"error":{"type":"string","description":"Error message"}}}}},"paths":{"/api/sandboxes/{sandbox_id}":{"patch":{"summary":"Update a sandbox","description":"Update sandbox name, sandbox email username.","tags":["Sandboxes"],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"sandbox":{"type":"object","properties":{"name":{"type":"string"},"email_username":{"type":"string"}}}}}}}},"responses":{"200":{"$ref":"#/components/responses/SandboxResponse"},"401":{"$ref":"#/components/responses/UNAUTHENTICATED"},"403":{"$ref":"#/components/responses/PERMISSION_DENIED"},"404":{"$ref":"#/components/responses/NOT_FOUND"}},"operationId":"updateSandbox"}}}}
```

## Clean sandbox

> Delete all messages (emails) from sandbox.

```json
{"openapi":"3.1.0","info":{"title":"Email Sandbox","version":"2.0.0"},"tags":[{"name":"Sandboxes","description":"Manage Sandboxes for email testing. Capture and inspect emails without delivering them to real recipients. This is ideal for development, staging, and QA environments.\n\n### Get your Sandbox ID\n\nTo use the Sandbox API, you need a Sandbox ID. You can get it in one of the following ways.\n\n#### Option 1: From the sandbox URL\n\n1. Open your Sandbox in Mailtrap.\n2. Copy the ID from the sandbox URL.\n\nExample:\n  - URL: https://mailtrap.io/sandboxes/2564102/settings\n  - Sandbox ID: 2564102\n\n#### Option 2: Via the API\n\nUse the `Get a list of sandboxes` endpoint to retrieve all Sandboxes in your account.\n"}],"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","in":"header","name":"Api-Token"},"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT"}},"responses":{"SandboxResponse":{"description":"Returns attributes of the sandbox.\n- **permissions** returns the permissions of the token for the sandbox.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TestingSandbox"}}}},"UNAUTHENTICATED":{"description":"Returns unauthorized error message. Check your credentials.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnauthenticatedResponse"}}}},"PERMISSION_DENIED":{"description":"Returns forbidden error message. Check your permissions.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PermissionsDeniedResponse"}}}},"NOT_FOUND":{"description":"Returns not found error message","content":{"application/json":{"schema":{"$ref":"#/components/schemas/NotFoundResponse"}}}}},"schemas":{"TestingSandbox":{"title":"Testing Sandbox","type":"object","properties":{"id":{"type":"integer"},"name":{"type":"string"},"username":{"type":"string"},"password":{"type":"string","nullable":true,"description":"Password is only available if you have admin permissions for the sandbox."},"max_size":{"type":"integer"},"status":{"type":"string","enum":["active","inactive","pending"]},"email_username":{"type":"string"},"email_username_enabled":{"type":"boolean"},"sent_messages_count":{"type":"integer"},"forwarded_messages_count":{"type":"integer"},"used":{"type":"boolean"},"forward_from_email_address":{"type":"string"},"project_id":{"type":"integer"},"domain":{"type":"string"},"pop3_domain":{"type":"string"},"email_domain":{"type":"string"},"api_domain":{"type":"string"},"emails_count":{"type":"integer"},"emails_unread_count":{"type":"integer"},"last_message_sent_at":{"nullable":true,"type":"string"},"smtp_ports":{"type":"array","items":{"type":"integer"}},"pop3_ports":{"type":"array","items":{"type":"integer"}},"max_message_size":{"type":"integer"},"permissions":{"type":"object","properties":{"can_read":{"type":"boolean"},"can_update":{"type":"boolean"},"can_destroy":{"type":"boolean"},"can_leave":{"type":"boolean"}}}}},"UnauthenticatedResponse":{"title":"UnauthenticatedResponse","type":"object","properties":{"error":{"type":"string","description":"Error message"}}},"PermissionsDeniedResponse":{"title":"PermissionsDeniedResponse","type":"object","properties":{"errors":{"type":"string","description":"Error message"}}},"NotFoundResponse":{"title":"NotFoundResponse","type":"object","properties":{"error":{"type":"string","description":"Error message"}}}}},"paths":{"/api/sandboxes/{sandbox_id}/clean":{"patch":{"summary":"Clean sandbox","description":"Delete all messages (emails) from sandbox.","tags":["Sandboxes"],"responses":{"200":{"$ref":"#/components/responses/SandboxResponse"},"401":{"$ref":"#/components/responses/UNAUTHENTICATED"},"403":{"$ref":"#/components/responses/PERMISSION_DENIED"},"404":{"$ref":"#/components/responses/NOT_FOUND"}},"operationId":"cleanSandbox"}}}}
```

## Mark as read

> Mark all messages in the sandbox as read.

```json
{"openapi":"3.1.0","info":{"title":"Email Sandbox","version":"2.0.0"},"tags":[{"name":"Sandboxes","description":"Manage Sandboxes for email testing. Capture and inspect emails without delivering them to real recipients. This is ideal for development, staging, and QA environments.\n\n### Get your Sandbox ID\n\nTo use the Sandbox API, you need a Sandbox ID. You can get it in one of the following ways.\n\n#### Option 1: From the sandbox URL\n\n1. Open your Sandbox in Mailtrap.\n2. Copy the ID from the sandbox URL.\n\nExample:\n  - URL: https://mailtrap.io/sandboxes/2564102/settings\n  - Sandbox ID: 2564102\n\n#### Option 2: Via the API\n\nUse the `Get a list of sandboxes` endpoint to retrieve all Sandboxes in your account.\n"}],"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","in":"header","name":"Api-Token"},"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT"}},"responses":{"SandboxResponse":{"description":"Returns attributes of the sandbox.\n- **permissions** returns the permissions of the token for the sandbox.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TestingSandbox"}}}},"UNAUTHENTICATED":{"description":"Returns unauthorized error message. Check your credentials.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnauthenticatedResponse"}}}},"PERMISSION_DENIED":{"description":"Returns forbidden error message. Check your permissions.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PermissionsDeniedResponse"}}}},"NOT_FOUND":{"description":"Returns not found error message","content":{"application/json":{"schema":{"$ref":"#/components/schemas/NotFoundResponse"}}}}},"schemas":{"TestingSandbox":{"title":"Testing Sandbox","type":"object","properties":{"id":{"type":"integer"},"name":{"type":"string"},"username":{"type":"string"},"password":{"type":"string","nullable":true,"description":"Password is only available if you have admin permissions for the sandbox."},"max_size":{"type":"integer"},"status":{"type":"string","enum":["active","inactive","pending"]},"email_username":{"type":"string"},"email_username_enabled":{"type":"boolean"},"sent_messages_count":{"type":"integer"},"forwarded_messages_count":{"type":"integer"},"used":{"type":"boolean"},"forward_from_email_address":{"type":"string"},"project_id":{"type":"integer"},"domain":{"type":"string"},"pop3_domain":{"type":"string"},"email_domain":{"type":"string"},"api_domain":{"type":"string"},"emails_count":{"type":"integer"},"emails_unread_count":{"type":"integer"},"last_message_sent_at":{"nullable":true,"type":"string"},"smtp_ports":{"type":"array","items":{"type":"integer"}},"pop3_ports":{"type":"array","items":{"type":"integer"}},"max_message_size":{"type":"integer"},"permissions":{"type":"object","properties":{"can_read":{"type":"boolean"},"can_update":{"type":"boolean"},"can_destroy":{"type":"boolean"},"can_leave":{"type":"boolean"}}}}},"UnauthenticatedResponse":{"title":"UnauthenticatedResponse","type":"object","properties":{"error":{"type":"string","description":"Error message"}}},"PermissionsDeniedResponse":{"title":"PermissionsDeniedResponse","type":"object","properties":{"errors":{"type":"string","description":"Error message"}}},"NotFoundResponse":{"title":"NotFoundResponse","type":"object","properties":{"error":{"type":"string","description":"Error message"}}}}},"paths":{"/api/sandboxes/{sandbox_id}/all_read":{"patch":{"summary":"Mark as read","description":"Mark all messages in the sandbox as read.","tags":["Sandboxes"],"responses":{"200":{"$ref":"#/components/responses/SandboxResponse"},"401":{"$ref":"#/components/responses/UNAUTHENTICATED"},"403":{"$ref":"#/components/responses/PERMISSION_DENIED"},"404":{"$ref":"#/components/responses/NOT_FOUND"}},"operationId":"markAsReadSandbox"}}}}
```

## Reset credentials

> Reset SMTP credentials of the sandbox.

```json
{"openapi":"3.1.0","info":{"title":"Email Sandbox","version":"2.0.0"},"tags":[{"name":"Sandboxes","description":"Manage Sandboxes for email testing. Capture and inspect emails without delivering them to real recipients. This is ideal for development, staging, and QA environments.\n\n### Get your Sandbox ID\n\nTo use the Sandbox API, you need a Sandbox ID. You can get it in one of the following ways.\n\n#### Option 1: From the sandbox URL\n\n1. Open your Sandbox in Mailtrap.\n2. Copy the ID from the sandbox URL.\n\nExample:\n  - URL: https://mailtrap.io/sandboxes/2564102/settings\n  - Sandbox ID: 2564102\n\n#### Option 2: Via the API\n\nUse the `Get a list of sandboxes` endpoint to retrieve all Sandboxes in your account.\n"}],"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","in":"header","name":"Api-Token"},"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT"}},"responses":{"SandboxResponse":{"description":"Returns attributes of the sandbox.\n- **permissions** returns the permissions of the token for the sandbox.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TestingSandbox"}}}},"UNAUTHENTICATED":{"description":"Returns unauthorized error message. Check your credentials.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnauthenticatedResponse"}}}},"PERMISSION_DENIED":{"description":"Returns forbidden error message. Check your permissions.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PermissionsDeniedResponse"}}}},"NOT_FOUND":{"description":"Returns not found error message","content":{"application/json":{"schema":{"$ref":"#/components/schemas/NotFoundResponse"}}}}},"schemas":{"TestingSandbox":{"title":"Testing Sandbox","type":"object","properties":{"id":{"type":"integer"},"name":{"type":"string"},"username":{"type":"string"},"password":{"type":"string","nullable":true,"description":"Password is only available if you have admin permissions for the sandbox."},"max_size":{"type":"integer"},"status":{"type":"string","enum":["active","inactive","pending"]},"email_username":{"type":"string"},"email_username_enabled":{"type":"boolean"},"sent_messages_count":{"type":"integer"},"forwarded_messages_count":{"type":"integer"},"used":{"type":"boolean"},"forward_from_email_address":{"type":"string"},"project_id":{"type":"integer"},"domain":{"type":"string"},"pop3_domain":{"type":"string"},"email_domain":{"type":"string"},"api_domain":{"type":"string"},"emails_count":{"type":"integer"},"emails_unread_count":{"type":"integer"},"last_message_sent_at":{"nullable":true,"type":"string"},"smtp_ports":{"type":"array","items":{"type":"integer"}},"pop3_ports":{"type":"array","items":{"type":"integer"}},"max_message_size":{"type":"integer"},"permissions":{"type":"object","properties":{"can_read":{"type":"boolean"},"can_update":{"type":"boolean"},"can_destroy":{"type":"boolean"},"can_leave":{"type":"boolean"}}}}},"UnauthenticatedResponse":{"title":"UnauthenticatedResponse","type":"object","properties":{"error":{"type":"string","description":"Error message"}}},"PermissionsDeniedResponse":{"title":"PermissionsDeniedResponse","type":"object","properties":{"errors":{"type":"string","description":"Error message"}}},"NotFoundResponse":{"title":"NotFoundResponse","type":"object","properties":{"error":{"type":"string","description":"Error message"}}}}},"paths":{"/api/sandboxes/{sandbox_id}/reset_credentials":{"patch":{"summary":"Reset credentials","description":"Reset SMTP credentials of the sandbox.","tags":["Sandboxes"],"responses":{"200":{"$ref":"#/components/responses/SandboxResponse"},"401":{"$ref":"#/components/responses/UNAUTHENTICATED"},"403":{"$ref":"#/components/responses/PERMISSION_DENIED"},"404":{"$ref":"#/components/responses/NOT_FOUND"}},"operationId":"resetSandboxCredentials"}}}}
```

## Enable email address

> Turn the email address of the sandbox on/off.

```json
{"openapi":"3.1.0","info":{"title":"Email Sandbox","version":"2.0.0"},"tags":[{"name":"Sandboxes","description":"Manage Sandboxes for email testing. Capture and inspect emails without delivering them to real recipients. This is ideal for development, staging, and QA environments.\n\n### Get your Sandbox ID\n\nTo use the Sandbox API, you need a Sandbox ID. You can get it in one of the following ways.\n\n#### Option 1: From the sandbox URL\n\n1. Open your Sandbox in Mailtrap.\n2. Copy the ID from the sandbox URL.\n\nExample:\n  - URL: https://mailtrap.io/sandboxes/2564102/settings\n  - Sandbox ID: 2564102\n\n#### Option 2: Via the API\n\nUse the `Get a list of sandboxes` endpoint to retrieve all Sandboxes in your account.\n"}],"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","in":"header","name":"Api-Token"},"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT"}},"responses":{"SandboxResponse":{"description":"Returns attributes of the sandbox.\n- **permissions** returns the permissions of the token for the sandbox.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TestingSandbox"}}}},"UNAUTHENTICATED":{"description":"Returns unauthorized error message. Check your credentials.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnauthenticatedResponse"}}}},"PERMISSION_DENIED":{"description":"Returns forbidden error message. Check your permissions.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PermissionsDeniedResponse"}}}},"NOT_FOUND":{"description":"Returns not found error message","content":{"application/json":{"schema":{"$ref":"#/components/schemas/NotFoundResponse"}}}}},"schemas":{"TestingSandbox":{"title":"Testing Sandbox","type":"object","properties":{"id":{"type":"integer"},"name":{"type":"string"},"username":{"type":"string"},"password":{"type":"string","nullable":true,"description":"Password is only available if you have admin permissions for the sandbox."},"max_size":{"type":"integer"},"status":{"type":"string","enum":["active","inactive","pending"]},"email_username":{"type":"string"},"email_username_enabled":{"type":"boolean"},"sent_messages_count":{"type":"integer"},"forwarded_messages_count":{"type":"integer"},"used":{"type":"boolean"},"forward_from_email_address":{"type":"string"},"project_id":{"type":"integer"},"domain":{"type":"string"},"pop3_domain":{"type":"string"},"email_domain":{"type":"string"},"api_domain":{"type":"string"},"emails_count":{"type":"integer"},"emails_unread_count":{"type":"integer"},"last_message_sent_at":{"nullable":true,"type":"string"},"smtp_ports":{"type":"array","items":{"type":"integer"}},"pop3_ports":{"type":"array","items":{"type":"integer"}},"max_message_size":{"type":"integer"},"permissions":{"type":"object","properties":{"can_read":{"type":"boolean"},"can_update":{"type":"boolean"},"can_destroy":{"type":"boolean"},"can_leave":{"type":"boolean"}}}}},"UnauthenticatedResponse":{"title":"UnauthenticatedResponse","type":"object","properties":{"error":{"type":"string","description":"Error message"}}},"PermissionsDeniedResponse":{"title":"PermissionsDeniedResponse","type":"object","properties":{"errors":{"type":"string","description":"Error message"}}},"NotFoundResponse":{"title":"NotFoundResponse","type":"object","properties":{"error":{"type":"string","description":"Error message"}}}}},"paths":{"/api/sandboxes/{sandbox_id}/toggle_email_username":{"patch":{"summary":"Enable email address","description":"Turn the email address of the sandbox on/off.","tags":["Sandboxes"],"responses":{"200":{"$ref":"#/components/responses/SandboxResponse"},"401":{"$ref":"#/components/responses/UNAUTHENTICATED"},"403":{"$ref":"#/components/responses/PERMISSION_DENIED"},"404":{"$ref":"#/components/responses/NOT_FOUND"}},"operationId":"enableSandboxEmailAddresses"}}}}
```

## Reset email address

> Reset username of email address per sandbox.

```json
{"openapi":"3.1.0","info":{"title":"Email Sandbox","version":"2.0.0"},"tags":[{"name":"Sandboxes","description":"Manage Sandboxes for email testing. Capture and inspect emails without delivering them to real recipients. This is ideal for development, staging, and QA environments.\n\n### Get your Sandbox ID\n\nTo use the Sandbox API, you need a Sandbox ID. You can get it in one of the following ways.\n\n#### Option 1: From the sandbox URL\n\n1. Open your Sandbox in Mailtrap.\n2. Copy the ID from the sandbox URL.\n\nExample:\n  - URL: https://mailtrap.io/sandboxes/2564102/settings\n  - Sandbox ID: 2564102\n\n#### Option 2: Via the API\n\nUse the `Get a list of sandboxes` endpoint to retrieve all Sandboxes in your account.\n"}],"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","in":"header","name":"Api-Token"},"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT"}},"responses":{"SandboxResponse":{"description":"Returns attributes of the sandbox.\n- **permissions** returns the permissions of the token for the sandbox.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TestingSandbox"}}}},"UNAUTHENTICATED":{"description":"Returns unauthorized error message. Check your credentials.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnauthenticatedResponse"}}}},"PERMISSION_DENIED":{"description":"Returns forbidden error message. Check your permissions.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PermissionsDeniedResponse"}}}},"NOT_FOUND":{"description":"Returns not found error message","content":{"application/json":{"schema":{"$ref":"#/components/schemas/NotFoundResponse"}}}}},"schemas":{"TestingSandbox":{"title":"Testing Sandbox","type":"object","properties":{"id":{"type":"integer"},"name":{"type":"string"},"username":{"type":"string"},"password":{"type":"string","nullable":true,"description":"Password is only available if you have admin permissions for the sandbox."},"max_size":{"type":"integer"},"status":{"type":"string","enum":["active","inactive","pending"]},"email_username":{"type":"string"},"email_username_enabled":{"type":"boolean"},"sent_messages_count":{"type":"integer"},"forwarded_messages_count":{"type":"integer"},"used":{"type":"boolean"},"forward_from_email_address":{"type":"string"},"project_id":{"type":"integer"},"domain":{"type":"string"},"pop3_domain":{"type":"string"},"email_domain":{"type":"string"},"api_domain":{"type":"string"},"emails_count":{"type":"integer"},"emails_unread_count":{"type":"integer"},"last_message_sent_at":{"nullable":true,"type":"string"},"smtp_ports":{"type":"array","items":{"type":"integer"}},"pop3_ports":{"type":"array","items":{"type":"integer"}},"max_message_size":{"type":"integer"},"permissions":{"type":"object","properties":{"can_read":{"type":"boolean"},"can_update":{"type":"boolean"},"can_destroy":{"type":"boolean"},"can_leave":{"type":"boolean"}}}}},"UnauthenticatedResponse":{"title":"UnauthenticatedResponse","type":"object","properties":{"error":{"type":"string","description":"Error message"}}},"PermissionsDeniedResponse":{"title":"PermissionsDeniedResponse","type":"object","properties":{"errors":{"type":"string","description":"Error message"}}},"NotFoundResponse":{"title":"NotFoundResponse","type":"object","properties":{"error":{"type":"string","description":"Error message"}}}}},"paths":{"/api/sandboxes/{sandbox_id}/reset_email_username":{"patch":{"summary":"Reset email address","description":"Reset username of email address per sandbox.","tags":["Sandboxes"],"responses":{"200":{"$ref":"#/components/responses/SandboxResponse"},"401":{"$ref":"#/components/responses/UNAUTHENTICATED"},"403":{"$ref":"#/components/responses/PERMISSION_DENIED"},"404":{"$ref":"#/components/responses/NOT_FOUND"}},"operationId":"resetEmailUserNamePerSandbox"}}}}
```


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.mailtrap.io/developers/email-sandbox/sandboxes.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
