---
title: "media.replica.draining@1 · OpenVibe.Services"
canonical: "https://openvibe.services/docs/contracts/media.replica.draining"
updated: null
---

# media.replica.draining@1 · OpenVibe.Services

HTML: [media.replica.draining@1 · OpenVibe.Services](https://openvibe.services/docs/contracts/media.replica.draining)

# MediaReplicaDrainingPayload `media.replica.draining@1`

Generated at 2026-12-01 05:42:00 UTC from [`openvibe-contracts v0.454.0`](https://github.com/OpenVibers/OpenVibe.Contracts/tree/v0.454.0) and [`openvibe-sdk v0.193.0`](https://github.com/OpenVibers/OpenVibe.SDK/tree/v0.193.0).

- Version: 1.0.0
- Owner: media
- Visibility: first-party
- Status: active
- Compatibility: backward
- Schema: [`https://openvibe.network/contracts/events/payloads/media.replica.draining.v1.json`](/docs/contracts/media.replica.draining.json)

media.replica.draining v1 (OpenVibe.Media server/objects/tiering.js demote(), the recordPlacement before the replica is deleted; PR #18). Media decided to drain a replica: the canonical copy has been confirmed good, the replica is about to be removed, and reads should stop being routed to it. Recorded before the delete, so a draining with no following media.replica.evicted means the delete failed and the replica is still there. Envelope: subject { type: object, id: <object\_id> }, visibility internal, priority low, actor service:media, source media. Sandbox tenants produce none.

## Fields

| Field | Type | Required | Description | Constraints |
| --- | --- | --- | --- | --- |
| `object_id` | string | yes |  | - `pattern ^med_[0-9A-HJKMNP-TV-Z]{26}$` |
| `app_id` | string \| null | yes | The tenant that owns the object: an app (live, tools…) or a developer project's production tenant (prj\_…); null when the object has no tenant. | - `minLength 1`<br>- `maxLength 200` |
| `class` | enum | yes | The placement class the move was budgeted against (media.storage\_policy classes; tiering.classOf). | - `one of "video", "image", "download", "game-asset", "attachment", "backup"` |
| `action` | const | yes | Draining is always part of a demotion. | - `= "demote"` |
| `provider` | enum | yes | The provider whose replica is being drained. | - `one of "local", "b2", "r2"` |
| `key` | string | yes | The object key of the replica being removed. | - `minLength 1`<br>- `maxLength 1024` |

## Examples

From the contract's own test fixtures: valid ones validate, rejected ones must fail.

 Valid: drain-r2

~~~~
{
  "object_id": "med_01JAB2C3D4E5F6G7H8J9K0MNPQ",
  "app_id": "live",
  "class": "video",
  "action": "demote",
  "provider": "r2",
  "key": "vods/med_01JAB2C3D4E5F6G7H8J9K0MNPQ.mp4"
}
~~~~

Rejected: leaks-bytes

~~~~
{
  "object_id": "med_01JAB2C3D4E5F6G7H8J9K0MNPQ",
  "app_id": "live",
  "class": "video",
  "action": "demote",
  "provider": "r2",
  "key": "vods/med_01JAB2C3D4E5F6G7H8J9K0MNPQ.mp4",
  "bytes": 1048576
}
~~~~

Rejected: promote-action

~~~~
{
  "object_id": "med_01JAB2C3D4E5F6G7H8J9K0MNPQ",
  "app_id": "live",
  "class": "video",
  "action": "promote",
  "provider": "r2",
  "key": "vods/med_01JAB2C3D4E5F6G7H8J9K0MNPQ.mp4"
}
~~~~

## Validate

~~~~
const contracts = require('openvibe-contracts');
contracts.validate('media.replica.draining@1', value);   // { valid, errors: [{ path, message }] }
~~~~
