Sensitive data

Rule: Sensitive data in URLs or headers [sens-dat]

Sensitive data SHOULD be put in a message payload instead of path, query or HTTP header parameters. Even though these parameters are encrypted during HTTPS transit, they are often stored in server and infrastructure logs, caches and browser history, which increases their exposure. The Authorization and Cookie HTTP headers are an exception, as they are recognized by infrastructure as sensitive and not logged.

For operations that would otherwise be modeled as URLs containing sensitive data, the sensitive data SHOULD instead be put in the request payload of a POST operation. A verb suffix get, update, delete or search SHOULD be used for operations that would otherwise not use the POST method. Resource linking, caching or embedding are not possible for such URLs.

For a single type of interaction with an entity (e.g. get, update, delete or search), avoid introducing multiple API operations. Searching usually supports more parameters, so is more often sensitive.

If sensitive data needs to be fully hidden from middleboxes, clients or servers, even in the message payload, consider alternatives like end-to-end encryption or pseudonymization.

interaction suffix original URL example safe URL example

consult document

/get

GET /accounts/{emailAddress}

POST /accounts/get

{
  "emailAddress": "{emailAddress}"
}

update document

/update

PUT /accounts/{emailAddress}

PATCH /accounts/{emailAddress}

{
  # new account data
}

POST /accounts/update

{
  "emailAddress": "{emailAddress}",
  # new account data
}

delete document

/delete

DELETE /accounts/{emailAddress}

POST /accounts/delete

{
  "emailAddress": "{emailAddress}"
}

consult collection

/search

GET /cases?createdBy={emailAddress}

POST /cases/search

{
  "createdBy": "{emailAddress}"
}

(same format as complex collection searches)

create a document

none

POST /accounts

POST /accounts (no change required)

controller resource

none

POST /accounts/{emailAddress}/deactivate

POST /accounts/deactivate

{
  "emailAddress": "user@example.com"
}

When a resource with sensitive identifier has child resources that don’t have sensitive identifiers, put all identifiers in the request payload.

original URL safe URL example

GET /accounts/{emailAddress}/profilePictures/{profilePictureId}

POST /accounts/profilePictures/get

{
  "emailAddress": "{emailAddress}",
  "profilePictureId": "{profilePictureId}"
}

POST /accounts/{emailAddress}/profilePictures

with picture as binary request body

POST /accounts/profilePictures

{
  "emailAddress": "{emailAddress}",
  "picture": "base64-encoded-image-data"
}

A multipart request with a separate body part for the picture can also be used in this example.