Make a copy of a database primary
const url = 'https://opfield.example.com/api/databases/managed/550e8400-e29b-41d4-a716-446655440000/availability/make-primary';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"memberId":"2489E9AD-2EE2-8E00-8EC9-32D5F69181C0","acceptDataLoss":true}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://opfield.example.com/api/databases/managed/550e8400-e29b-41d4-a716-446655440000/availability/make-primary \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "memberId": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "acceptDataLoss": true }'A planned switch (the primary serves and the copy is eligible) loses nothing. When the primary is gone or no copy is eligible, the switch can lose recent writes: it is refused with 409 AVAILABILITY_LOSSY_PROMOTION and the estimate (details.lossBytes) unless the body has acceptDataLoss: true. A replicated pair without automatic failover switches as planned only while its primary reports: the primary steps down and confirms it before the copy is promoted (the operation fails and promotes nothing without that confirmation), and the copy must stream within the lag bound (409 AVAILABILITY_COPY_NOT_STREAMING unless acceptDataLoss). A primary that does not report is waited for until it was last seen 45 s ago (409 AVAILABILITY_PRIMARY_RECENTLY_SEEN with the seconds left). A member running another database cluster than the primary is never made primary (409 AVAILABILITY_OTHER_CLUSTER). A second switch while one runs is refused (409 AVAILABILITY_OPERATION_PENDING). A member whose server does not report is refused with 409 AVAILABILITY_MEMBER_NOT_CONNECTED (details.memberId, details.nodeId, details.lastReportedAt). Needs databases:edit. Keeps working on an existing set after the license grace period.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”Example
550e8400-e29b-41d4-a716-446655440000Request Bodyrequired
Section titled “Request Bodyrequired”JSON request body
object
Examplegenerated
{ "memberId": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "acceptDataLoss": true}Responses
Section titled “Responses”Started
object
object
Automatic | manual. manual: a replicated pair without automatic failover (no witness host); make a copy primary by hand
Converting | healthy | degraded | no_failover | failing_over | closing | error | paused (the resource is paused)
object
Synchronous | asynchronous
Auto | admin
What an unplanned failover can lose with this durability
object
Failover preference: higher first, then the older member. members lists the servers in this order, which PUT availability/members/order sets
Primary | copy | rebuilding | fenced | unknown
It still reports itself primary but lost the role in a failover (role shows unknown until it reports)
Whether this copy may take over now
Sync | async | none
Creating | ready | error | removing
Member | removing
The member reported recently
object
Lease | keeper
Relay | node
Active | standby
Servers the set can lose now and keep its primary role
object
How long failover keeps working while Opfield is down (the relay policy lease)
object
object
object
Set when the license no longer covers changes: turning on, adding servers, settings and the failover order are refused; everything else keeps working
Example
{ "data": { "id": "550e8400-e29b-41d4-a716-446655440000", "name": "Example resource" }}Bad request
object
Error code
Human-readable error message
Additional error details
Example
{ "code": "VALIDATION_ERROR", "message": "Request validation failed", "details": [ { "path": [ "name" ], "message": "Required" } ]}Authentication required
object
Error code
Human-readable error message
Additional error details
Example
{ "code": "UNAUTHORIZED", "message": "Authentication required"}Forbidden
object
Error code
Human-readable error message
Additional error details
Example
{ "code": "FORBIDDEN", "message": "Insufficient permissions"}Not found
object
Error code
Human-readable error message
Additional error details
Example
{ "code": "NOT_FOUND", "message": "Resource not found"}Conflict
object
Error code
Human-readable error message
Additional error details
Example
{ "code": "CONFLICT", "message": "Resource already exists"}Unprocessable entity
object
Error code
Human-readable error message
Additional error details
Example
{ "code": "UNPROCESSABLE_ENTITY", "message": "Request could not be processed"}Internal server error
object
Error code
Human-readable error message
Additional error details
Example
{ "code": "INTERNAL_ERROR", "message": "Internal server error"}