> ## Documentation Index
> Fetch the complete documentation index at: https://www.recraft.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Zero data retention

> Send Recraft API requests with the zdr parameter so that request inputs, such as the prompt or images, are not stored or logged.

Zero data retention (ZDR) means that request inputs, such as the prompt or images, are not stored or logged. Turn it on for a request with the `zdr` parameter.

## What is kept

For a request with zero data retention on:

| Data | What happens |
| - | - |
| `prompt`, `negative_prompt` | Not stored and not logged. |
| Input images and masks, sent as files, URLs, or data URLs | Their bytes are not stored and not logged. |
| Output images with `response_format` `b64_json` or `multipart` | Returned in the response, not stored and not logged. |
| Output images with `response_format` `url` (default) | Uploaded to storage so that the URL can be served, and kept the same way as without `zdr`. See [Image storage](https://www.recraft.ai/docs/api-reference/appendix.md#image-storage). |

Request metadata is still recorded: for example the operation, the model, the content type, dimensions, and size in bytes of every result image, etc.

The response has the same shape as without `zdr`.

## Parameter

| Parameter | Type | Description |
| - | - | - |
| `zdr` | boolean | `true` turns zero data retention on for the request, `false` turns it off. When omitted, the default of your account applies: off, unless zero data retention is enabled for your account. |

In a JSON body `zdr` is a boolean member. In a `multipart/form-data` body it is a form field with the value `true` or `false`.

## Example

This request generates an image with zero data retention. It also sets `response_format` to `b64_json`, so the image comes back in the response and is not stored:

```bash cURL theme={null}
curl https://external.api.recraft.ai/v1/images/generations \
  -H "Authorization: Bearer $RECRAFT_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "two race cars on a track",
    "model": "recraftv4_1",
    "zdr": true,
    "response_format": "b64_json"
  }'
```

```python Python theme={null}
# pip install requests
import base64
import os

import requests

response = requests.post(
    'https://external.api.recraft.ai/v1/images/generations',
    headers={'Authorization': f"Bearer {os.environ['RECRAFT_API_TOKEN']}"},
    json={
        'prompt': 'two race cars on a track',
        'model': 'recraftv4_1',
        'zdr': True,
        'response_format': 'b64_json',
    },
)
if not response.ok:
    raise SystemExit(f'{response.status_code}: {response.text}')
with open('image.webp', 'wb') as f:
    f.write(base64.b64decode(response.json()['data'][0]['b64_json']))
```

With an uploaded file, `zdr` is a form field:

```bash cURL theme={null}
curl https://external.api.recraft.ai/v1/images/removeBackground \
  -H "Authorization: Bearer $RECRAFT_API_TOKEN" \
  -F "file=@image.png" \
  -F "zdr=true" \
  -F "response_format=b64_json"
```

```python Python theme={null}
import base64
import os

import requests

with open('image.png', 'rb') as image:
    response = requests.post(
        'https://external.api.recraft.ai/v1/images/removeBackground',
        headers={'Authorization': f"Bearer {os.environ['RECRAFT_API_TOKEN']}"},
        data={'zdr': 'true', 'response_format': 'b64_json'},
        files={'file': image},
    )
if not response.ok:
    raise SystemExit(f'{response.status_code}: {response.text}')
with open('result.webp', 'wb') as f:
    f.write(base64.b64decode(response.json()['image']['b64_json']))
```

## Endpoints

These endpoints take `zdr`:

| Endpoint | Request | Docs |
| - | - | - |
| Generate image | `POST /images/generations`, `POST /images/generations/raster`, `POST /images/generations/vector` | [Generate image](https://www.recraft.ai/docs/api-reference/endpoints.md#generate-image) |
| Image to image | `POST /images/imageToImage` | [Image to image](https://www.recraft.ai/docs/api-reference/tools/image-to-image.md) |
| Inpainting | `POST /images/inpaint` | [Inpainting](https://www.recraft.ai/docs/api-reference/tools/inpainting.md) |
| Outpainting | `POST /images/outpaint` | [Outpainting](https://www.recraft.ai/docs/api-reference/tools/outpainting.md) |
| Replace background | `POST /images/replaceBackground` | [Background](https://www.recraft.ai/docs/api-reference/tools/background.md) |
| Generate background | `POST /images/generateBackground` | [Background](https://www.recraft.ai/docs/api-reference/tools/background.md#generate-background) |
| Vectorize | `POST /images/vectorize` | [Vectorize](https://www.recraft.ai/docs/api-reference/tools/vectorize.md) |
| Remove background | `POST /images/removeBackground` | [Remove background](https://www.recraft.ai/docs/api-reference/tools/remove-background.md) |
| Erase region | `POST /images/eraseRegion` | [Erase region](https://www.recraft.ai/docs/api-reference/tools/erase-region.md) |
| Crisp upscale | `POST /images/crispUpscale` | [Upscale](https://www.recraft.ai/docs/api-reference/tools/upscale.md) |
| Creative upscale | `POST /images/creativeUpscale` | [Upscale](https://www.recraft.ai/docs/api-reference/tools/upscale.md#creative-upscale) |
| Enhance details | `POST /images/enhance` | [Enhance details](https://www.recraft.ai/docs/api-reference/tools/enhance-details.md) |
| Remix image | `POST /images/variateImage` | [Remix](https://www.recraft.ai/docs/api-reference/tools/remix.md) |
| Enhance prompt | `POST /prompts/enhance` | [Enhance prompt](https://www.recraft.ai/docs/api-reference/tools/enhance-prompt.md) |

[Create style](https://www.recraft.ai/docs/api-reference/endpoints.md#create-style) doesn't take `zdr`: a style stores its reference images so that it can be reused. The endpoints that list, get, or delete styles and [User information](https://www.recraft.ai/docs/api-reference/endpoints.md#get-user-information) don't take it either.

## Restrictions

* **Style references.** `style_references` and `style_reference_urls` can't be used with zero data retention, because they create a stored style during the request. Such a request is rejected. Pass the `style_id` of a style you created earlier instead.
* **Account default.** When zero data retention is enabled for your account, the restriction above also applies to requests that omit `zdr`. Send `zdr: false` to turn zero data retention off for one request.

Every model, `response_format`, and `image_format` works with `zdr`.

## Related

> [card] [Image inputs and results](https://www.recraft.ai/docs/api-reference/image-inputs-and-results.md)
>
> Send images as files, URLs, or data URLs, and pick the response format.

> [card] [Limits and sizes](https://www.recraft.ai/docs/api-reference/appendix.md#image-storage)
>
> How long result URLs are kept.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.