Skip to Content
Docs
Forward requests

Forward a request

POST/forward_requests

Sends the provider's request to its destination with the placeholders filled in, and returns the provider's answer.

When the provider answers, whatever its status, the response is 200 with the provider's reply inside: read response.status for the provider's result. Before the reply comes back, Pay.com saves the cards at your response.tokenize paths and puts their token in their place, applies your response.redact paths, then masks any other card number in the body and the headers to its first six and last four digits. Saving a card that's already in your vault returns its existing token.

Pay.com doesn't follow redirects: a 3xx comes back as the provider's answer. A compressed reply is decompressed, and a reply body that isn't JSON comes back as UTF-8 text.

When Pay.com can't get an answer from the provider, the error's upstream_sent says whether the provider got the request. See Errors.

Headers

AuthorizationstringRequired
HTTP Basic auth: your API key as the password, with an empty username. See Authentication.
Idempotency-Keystring

Makes a retry safe. A retry with the same key gets the first answer again when the first attempt reached the provider, or might have. 1 to 255 printable ASCII characters, without spaces, kept for 24 hours.

Parameters

destinationstringRequired

The destination's id.

requestobjectRequired

The provider's request, with placeholders for card data and stored credentials.

Show 4 child parametersHide child parameters
methodstringRequired

One of GET, POST, PUT, PATCH or DELETE.

urlstringRequired

The provider's full URL: https://, on the destination's host and port, under one of its path prefixes. No placeholders, user name or password.

headersobject

Header names and string values, up to 64. Placeholders go in the values. Pay.com sets Host, Content-Length, Transfer-Encoding, Connection and the other connection headers itself, so a request that sends them is refused.

bodyobject or string

The provider's body, with placeholders in its string values: a JSON object, sent as JSON, or a string, sent as it is, for XML or a form. A JSON object needs a JSON Content-Type, or none.

responseobject

What to do with card data in the provider's JSON reply. Any other card number is masked.

Show 2 child parametersHide child parameters
tokenizearray of objects

Card numbers to save as Pay.com tokens. A card that can't be saved is replaced with "[REDACTED]".

Show 3 child parametersHide child parameters
json_pathstringRequired

The card number, such as $.card.number.

exp_monthstringRequired

The card's expiry month, in the same reply.

exp_yearstringRequired

The card's expiry year, in the same reply.

redactarray of strings

Fields to replace with "[REDACTED]". [*] stands for every item of a list.

Returns

The provider answered. Its status, headers and body are in response.

idstring

The forward's id, also in the x-pay-com-forward-id header.

resourcestring

One of forward_request.

destinationstring

The destination's id.

responseobject

The provider's answer.

Show 3 child attributesHide child attributes
statusinteger

The provider's HTTP status.

headersobject

The provider's headers, without Set-Cookie, Content-Length, Content-Encoding and the connection headers.

bodyobject or string

The provider's body: an object for JSON, a string for anything else.

tokenizedarray of objects

One entry for each response.tokenize path.

Show 3 child attributesHide child attributes
json_pathstring

The path, as you sent it.

tokenstring

The saved card's token, now at that path.

errorstring

Set instead of token when the card couldn't be saved.

One of tokenize_failed.

timingobject
Show 2 child attributesHide child attributes
total_msinteger

The time the forward took, in milliseconds.

upstream_msinteger

The time the provider took, in milliseconds.

Errors

400
The request isn't valid, for example a placeholder in the URL. The message names the field.
401
The request has no API key that starts sk-pay-com-, as Basic or Bearer auth.
403
The request doesn't match the destination, or names a field or a credential the destination doesn't allow.
404
A tok_card_ or pm_card_ id isn't a card of your account.
409
The destination is waiting for review, or a request with this Idempotency-Key hasn't been answered yet. For the second, retry after the Retry-After header's seconds.
413
The request is over 5 MB, before or after the placeholders are filled.
422
The card can't be forwarded this way, its CVC is gone, or the Idempotency-Key was used for a different request.
429
Too many requests for your account or the destination. Retry after the Retry-After header's seconds.
500
Something went wrong on Pay.com's side. Nothing was sent; try again.
502
Pay.com couldn't connect to the provider, or the provider's reply is over 5 MB.
503
Pay.com couldn't check the API key, read the card or take the request. Nothing was sent. Retry after the Retry-After header's seconds.
504
The provider didn't answer in time, or Pay.com couldn't confirm the outcome.
Was this page helpful?