Replace a User

To replace an entire user resource, perform a PUT operation on the specific user resource. The only replaceable property is the id of the user. This replace operation does not impact the permissions of the user.

Request

Method Request URI Description
PUT https://{databaseaccount}.documents.azure.com/dbs/{db-id}/users/{user-name} The {databaseaccount} is the name of the Azure Cosmos DB account created under your subscription. The {db-id} value is the user generated name/id of the database where the user resides, not the system generated ID (rid). The {user-name} value is the name of the user to be replaced.

Headers

See Common Azure Cosmos DB REST request headers for headers that are used by all Cosmos DB requests.

Body

Property Required Type Description
id Required String Provide a new unique name for the user.
{  
    "id": "another_user"  
}  

Response

Headers

See Common Azure Cosmos DB REST response headers for headers that are returned by all Cosmos DB responses.

Status codes

The following table lists common status codes returned by this operation. For a full list of status codes, see HTTP Status Codes.

HTTP status code Description
200 Ok The replace operation was successful.
400 Bad Request The JSON body is invalid. Check for missing curly brackets or quotes.
404 Not Found The user to be replaced is no longer a resource, that is, the user has been deleted.
409 Conflict The ID provided for the user has been taken by an existing user.

Body

Property Description
_rid It is a system generated property. The resource ID (_rid) is a unique identifier that is also hierarchical per the resource stack on the resource model. It is used internally for placement of and navigation to the user resource.
_ts It is a system generated property. It specifies the last updated timestamp of the resource. The value is a timestamp.
_self It is a system generated property. It is the unique addressable URI for the resource.
_etag A new resource etag is generated.
_permissions It is a system generated property denoting the addressable path of the permissions resource.
{  
    "id": "another_user",  
    "_rid": "Sl8fAFEKCQA=",  
    "_ts": 1449604250,  
    "_self": "dbs\/Sl8fAA==\/users\/Sl8fAFEKCQA=\/",  
    "_etag": "\"00000c00-0000-0000-0000-5667349a0000\"",  
    "_permissions": "permissions\/"  
}  

Example

PUT https://contosomarketing.documents.azure.com/dbs/volcanodb/users/a_user HTTP/1.1  
x-ms-date: Tue, 08 Dec 2015 19:50:50 GMT  
authorization: type%3dmaster%26ver%3d1.0%26sig%3d%2by3RxtfXTgRnAMx2zwCmMFx%2bbKetAvuaGmVYeS1psjE%3d  
Cache-Control: no-cache  
User-Agent: contoso/1.0  
x-ms-version: 2015-08-06  
Accept: application/json  
Host: contosomarketing.documents.azure.com  
Content-Length: 148  
Expect: 100-continue  
Connection: Keep-Alive  
  
{  
    "id": "another_user",  
}  
  
HTTP/1.1 200 Ok  
Cache-Control: no-store, no-cache  
Pragma: no-cache  
Content-Type: application/json  
Content-Location: https://contosomarketing.documents.azure.com/dbs/volcanodb/users/a_user  
Server: Microsoft-HTTPAPI/2.0  
Strict-Transport-Security: max-age=31536000  
x-ms-last-state-change-utc: Sun, 29 Nov 2015 02:25:35.212 GMT  
etag: "00000c00-0000-0000-0000-5667349a0000"  
x-ms-resource-quota: users=500000;  
x-ms-resource-usage: users=2;  
x-ms-schemaversion: 1.1  
x-ms-alt-content-path: dbs/volcanodb  
x-ms-content-path: Sl8fAA==  
x-ms-quorum-acked-lsn: 862  
x-ms-session-token: 863  
x-ms-current-write-quorum: 3  
x-ms-current-replica-set-size: 4  
x-ms-request-charge: 9.9  
x-ms-serviceversion: version=1.5.57.3  
x-ms-activity-id: 8089fc55-a82c-432f-83d2-6a9ad712addd  
x-ms-gatewayversion: version=1.5.57.3  
Date: Tue, 08 Dec 2015 19:50:51 GMT  
Content-Length: 189  
  
{  
    "id": "another_user",  
    "_rid": "Sl8fAFEKCQA=",  
    "_ts": 1449604250,  
    "_self": "dbs\/Sl8fAA==\/users\/Sl8fAFEKCQA=\/",  
    "_etag": "\"00000c00-0000-0000-0000-5667349a0000\"",  
    "_permissions": "permissions\/"  
}  
  

See Also