Token Replacement in Request API
curl --request POST \
--url https://service.pcibooking.net/api/payments/paycard/relay \
--header 'Authorization: <api-key>'import requests
url = "https://service.pcibooking.net/api/payments/paycard/relay"
headers = {"Authorization": "<api-key>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: '<api-key>'}};
fetch('https://service.pcibooking.net/api/payments/paycard/relay', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://service.pcibooking.net/api/payments/paycard/relay",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://service.pcibooking.net/api/payments/paycard/relay"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("Authorization", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://service.pcibooking.net/api/payments/paycard/relay")
.header("Authorization", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://service.pcibooking.net/api/payments/paycard/relay")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
response = http.request(request)
puts response.read_bodyThe third-party response is returned as-is. The format and content depend entirely on the destination API.
Empty response body.
Authentication failed: the API key, session token or access token is missing or was not accepted.
See "Authentication and Permission Failures" on the Error Handling page.
{
"code": -125,
"message": "Bad input data",
"moreInfo": "Couldn't fetch a valid screening profile:: <profileName>",
"errorList": null
}
{
"code": -125,
"message": "Bad input data",
"moreInfo": "Invalid target Uri::",
"errorList": null
}
Token Replacement
Token Replacement in Request API
Replace card tokens with real card data and relay the request to a third-party API.
POST
/
api
/
payments
/
paycard
/
relay
Token Replacement in Request API
curl --request POST \
--url https://service.pcibooking.net/api/payments/paycard/relay \
--header 'Authorization: <api-key>'import requests
url = "https://service.pcibooking.net/api/payments/paycard/relay"
headers = {"Authorization": "<api-key>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: '<api-key>'}};
fetch('https://service.pcibooking.net/api/payments/paycard/relay', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://service.pcibooking.net/api/payments/paycard/relay",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://service.pcibooking.net/api/payments/paycard/relay"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("Authorization", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://service.pcibooking.net/api/payments/paycard/relay")
.header("Authorization", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://service.pcibooking.net/api/payments/paycard/relay")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
response = http.request(request)
puts response.read_bodyThe third-party response is returned as-is. The format and content depend entirely on the destination API.
Empty response body.
Authentication failed: the API key, session token or access token is missing or was not accepted.
See "Authentication and Permission Failures" on the Error Handling page.
{
"code": -125,
"message": "Bad input data",
"moreInfo": "Couldn't fetch a valid screening profile:: <profileName>",
"errorList": null
}
{
"code": -125,
"message": "Bad input data",
"moreInfo": "Invalid target Uri::",
"errorList": null
}
Token Replacement Guide
Replace tokens with card data in API requests
Error Responses
| Code | HTTP Status | Condition |
|---|---|---|
| -125 | 400 | httpMethod not POST/GET/PUT/PATCH/DELETE |
| -160 | 404 | Card data could not be retrieved for a token you can access |
| -150 | 500 | Card retrieval failed |
| -125 | 400 | Profile name provided but profile not found |
| -125 | 400 | Content replacement failed |
| -125 | 400 | Empty content body |
| -125 | 400 | Missing Content-Type header |
| -125 | 400 | Target URI invalid |
| -1003 | 401 | The cardToken is malformed, the token does not exist or was deleted, or you are not the owner and not associated with it. See Token Not Found or Not Accessible. |
Error detail
Each condition below gives the exactmoreInfo text, why it happens and how to resolve it. The full set is on the Error Handling page.
-125 Bad input data - profile not found
-125 Bad input data - profile not found
HTTP status: The first is returned by token replacement in a request (See also: Content Filters, Target Profiles
400message: Bad input datamoreInfo: the wording depends on which endpoint you called:Couldn't fetch a valid screening profile:: <profileName>
Couldn't fetch a valid pciShield profile:: <profileName>
paycard/relay). The second is returned by tokenization on response (paycard/capture). They mean the same thing.Reason. The profileName you passed could not be resolved for the account making the request. In almost every case the profile does exist, but on a different account than the one your credentials belong to. A misspelled profile name produces the same error.How to resolve.A PCI Shield profile belongs to the account, not to the sub-user that calls the API. When a sub-user makes a request, the profile is looked up against that sub-user’s parent account. A profile configured on one account is never visible to a sub-user of a different account, and sandbox and production accounts are separate.To check which profiles your credential can see:- Identify the parent account of the sub-user whose credentials you are using.
- Sign in to the PCI Booking portal as that account and open PCI Shield Settings > PCI Shield Profile Settings.
- Confirm the profile name appears there, spelled exactly as you send it. Profile names are matched exactly.
- If the profile is listed under a different account, switch your request to a sub-user of that account rather than copying the profile.
There is no API endpoint that lists the profiles on your own account.
GET /api/booker returns the platform-wide preset tokenization profiles, which are a different set. Your own profiles are visible in the portal only.-125 Bad input data - card data could not be substituted
-125 Bad input data - card data could not be substituted
HTTP status: Reason. The body parsed, but the profile’s selectors did not match anything in it, so no card data was substituted. The request was not relayed. This is a mismatch between the profile and the payload, not a problem with the token.How to resolve.
400message: Bad input datamoreInfo:Replacement of content failed
Could not apply token replacement onto content
- Compare the profile’s selectors against the exact payload you sent. A selector that assumes a different nesting depth or element name matches nothing.
- Check the namespaces. For XML and SOAP, a selector written without namespace handling will not match a namespaced document.
- Confirm the body is the format the profile was written for. A profile written for XML will not match a JSON body.
- Test the profile against a saved copy of a real request before using it in production.
-125 Bad input data - request body is empty
-125 Bad input data - request body is empty
HTTP status: Reason. Token replacement had nothing to work on. The body of the request you asked to be relayed was empty, so there was no content in which to substitute card data.How to resolve.
400message: Bad input datamoreInfo:Content is empty
Content is missing/empty
Empty relay message content
- Send the third-party request you want relayed as the body of the call, not as a query parameter.
- If you are pointing at the content with a parameter name, check that parameter is present and actually carries the payload.
- Check no proxy or client library between you and the API is dropping the body on a
GETrelay.
-125 Bad input data - Content-Type header missing
-125 Bad input data - Content-Type header missing
HTTP status: Reason. Token replacement needs to know how to parse the body before it can find the placeholders. Without a
400message: Bad input datamoreInfo:Content type is missing/empty
Content-Type header it cannot choose a parser.How to resolve.- Set
Content-Typeto match the body you are sending, for exampleapplication/json,text/xml, orapplication/x-www-form-urlencoded. - Send the charset if the third party requires one, for example
text/xml; charset=UTF-8.
-125 Bad input data - unsupported httpMethod value
-125 Bad input data - unsupported httpMethod value
HTTP status: Reason. The
400message: Bad input datamoreInfo:httpMethod should be 'POST','GET','PUT','PATCH','DELETE'
httpMethod parameter names a method the relay does not forward.How to resolve.- Use one of
POST,GET,PUT,PATCHorDELETE, in upper case. - Omit the parameter to accept the default of
POST.
-125 Bad input data - targetUri not usable
-125 Bad input data - targetUri not usable
HTTP status: Reason. The
400message: Bad input datamoreInfo:Target Uri invalid
targetUri could not be parsed as an absolute URL, so the relay had nowhere to send the request.How to resolve.- Send an absolute URL including the scheme, for example
https://api.example.com/path. - URL-encode the value if you pass it as a query parameter, so that its own query string does not terminate yours.
-125 Bad input data - no token found in the custom header
-125 Bad input data - no token found in the custom header
HTTP status: Reason. The relay was told to take the token from the
400message: Bad input datamoreInfo:Token(s) could not be found in custom header X-pciBooking-cardUri
X-pciBooking-cardUri header, but the header was absent or held no readable token.How to resolve.- Add the
X-pciBooking-cardUriheader carrying the full token URI. - Separate multiple tokens as the endpoint documents, and check none of them is empty.
-175 Request timed out - third party did not respond in time
-175 Request timed out - third party did not respond in time
HTTP status:
504message: Request timed outmoreInfo: not populated for this condition. The code and the endpoint are the only signal.Reason. PCI Booking relayed your request but the target server did not answer within the timeout. The failure is on the far side, not in PCI Booking. Card data may already have reached the third party, so the operation cannot be assumed not to have happened.How to resolve.- Check how long the third party takes to respond. The complete round trip must finish within 29 seconds, so raising
timeoutbeyond that does not help. If the third party regularly needs longer, contact support@pcibooking.net for an alternative setup. - Confirm the target host is reachable and not rate limiting or blocking the call. PCI Booking calls the third party from its own addresses, which the third party may need to allow.
- Do not blind retry a charge. Query the third party for the outcome first. A timeout is an unknown result, not a failure.
-1003 You are not authorized to access this resource - token does not exist, was deleted, or is not yours
-1003 You are not authorized to access this resource - token does not exist, was deleted, or is not yours
HTTP status: Reason. The credential authenticated fine, but it cannot act on the token in the request. Either the token does not exist or it is not yours to use. The generic wording makes this the single most misread error in the API. On a token call it is far more often one of the causes below than an actual permissions problem.How to resolve.
401message: You are not authorized to access this resource. Please contact customer support.moreInfo: one of the following, depending on which check failed:User is not the owner of this bank card
Merchant or Owner are not associated with bank card [<token>] userID: <userId>
User <userId> is not associated with bank card [<token>]
User <userId> cannot delegate token <token> - not owner and lacks delegation rights
User is not authorized to handle bank cards
- Check the token still exists. This is the most common cause. On every token endpoint except Delete Token, a token that does not exist or was deleted returns this error, the same as a token that belongs to another account. See Token Not Found or Not Accessible.
- Check the tokenization actually succeeded. If the call that should have created the token failed, the token never existed, and calls that use it report
-1003. - Check the environment. A sandbox token cannot be used from production, or the reverse.
- Check ownership and association. See the rules below.
- At tokenization, by passing
merchantIdon the tokenizing call. - After tokenization, by associating the token with the merchant.
- An association can only target a primary account. If you pass the ID of a sub-user or a secondary property, the request is rejected and you must associate the token with the parent account instead.
- Tokens never cross environments. A token created in sandbox cannot be used from production, and the reverse is also true.
403 and code -1003, even though the credentials are still valid and can still sign in to the portal. In this response message is empty (null) and moreInfo holds only the generic -1003 text, so nothing in the body explains the block. The 403 status is what tells it apart from a token that is not accessible, which returns 401.This is a common cause on sandbox accounts, which have a lower allowance than production.Check for it when a 403 with -1003 appears suddenly across calls that used to work, on more than one token. A block affects every billable call on the account at once, whereas a genuine ownership problem affects only the specific token. Contact support with your account name to have the allowance reviewed and the block lifted.Parameter Constraints
- cardToken must contain a valid card URI with a 32-hex token.
- targetUri is required.
- httpMethod defaults to POST. Accepted values: POST, GET, PUT, PATCH, DELETE.
- postResponseAction accepts
ClearCVVorDeleteToken.
All URLs must be HTTPS. URL-encode all query string components.
Parameters
Authentication
This is a browser-facing endpoint. Use one of the authentication methods below instead of the API key shown above.
string
Recommended. A long-lived token for browser-side calls. How to generate.
string
Alternative. Valid for 5 minutes. How to generate.
Query String
string
required
The token URI identifying the card in PCI Booking.
string
required
The HTTPS URL of the third party to relay the request to.
string
default:"POST"
The HTTP method to use when calling the target URI. One of:
POST, GET, PUT, PATCH, DELETE.string
The ID of a target profile configured for this request. If omitted, PCI Booking uses placeholder-based replacement instead. See Choosing a Replacement Mode.
string
For placeholder-based replacement: the name of the one parameter that contains the placeholders. PCI Booking looks for it first in the query string of
targetUri, then in the form body. Ignored if profileName is provided. If omitted, PCI Booking searches the whole request body for placeholders.string
Action to perform after a successful relay.
ClearCVV clears the CVV from the token. DeleteToken deletes the token entirely. If omitted, no action is taken.int
Seconds to wait for the third-party response before timing out. Default 60. The complete round trip must still finish within 29 seconds; see Timeouts.
Headers
string
Compression format:
gzip or deflate. Omit if no compression is needed.Request Body
The request body and headers are relayed to the third party as you send them, with card data inserted. Call this endpoint withPOST; the third party receives the method set in httpMethod. Structure the request as the third party’s API requires, including any headers it needs. See What PCI Booking Changes in Your Request.
Mark where card data goes with placeholders such as $~Number~$, or reference a target profile with profileName, as in the second example below.
Request Example
Send a JSON payment request to a third-party API, with PCI Booking replacing the card placeholders with real data before forwarding. You authenticate to PCI Booking with theaccessToken query parameter. Any Authorization header you send belongs to the third party and is forwarded to it.
The body is written as text so that the expiration month and year can be sent as JSON numbers, with their placeholders outside quotes. See Placeholders in JSON.
- curl
- Node.js
- Python
curl -X POST "https://service.pcibooking.net/api/payments/paycard/relay?accessToken=your-access-token&cardToken=https%3A%2F%2Fservice.pcibooking.net%2Fapi%2Fpayments%2Fpaycard%2F555fd7b49f134b42a5dbe4d576b2e527&targetUri=https%3A%2F%2Fapi.thirdparty.com%2Fv1%2Fpayments&httpMethod=POST" \
-H "Content-Type: application/json" \
-d '{
"amount": 250.00,
"currency": "USD",
"card": {
"number": "$~Number~$",
"expMonth": $~ExpirationM~$,
"expYear": $~ExpirationYYYY~$,
"cvv": "$~CVV~$",
"holderName": "$~OwnerName~$"
},
"reference": "order-98765"
}'
const params = new URLSearchParams({
accessToken: "your-access-token",
cardToken: "https://service.pcibooking.net/api/payments/paycard/555fd7b49f134b42a5dbe4d576b2e527",
targetUri: "https://api.thirdparty.com/v1/payments",
httpMethod: "POST"
});
// Built as text, not with JSON.stringify, so that the numeric
// placeholders stay outside quotes.
const body = `{
"amount": 250.00,
"currency": "USD",
"card": {
"number": "$~Number~$",
"expMonth": $~ExpirationM~$,
"expYear": $~ExpirationYYYY~$,
"cvv": "$~CVV~$",
"holderName": "$~OwnerName~$"
},
"reference": "order-98765"
}`;
const response = await fetch(
`https://service.pcibooking.net/api/payments/paycard/relay?${params}`,
{
method: "POST",
headers: { "Content-Type": "application/json" },
body
}
);
const data = await response.text();
console.log(data);
import requests
# Built as text, not with json=, so that the numeric
# placeholders stay outside quotes.
body = """{
"amount": 250.00,
"currency": "USD",
"card": {
"number": "$~Number~$",
"expMonth": $~ExpirationM~$,
"expYear": $~ExpirationYYYY~$,
"cvv": "$~CVV~$",
"holderName": "$~OwnerName~$"
},
"reference": "order-98765"
}"""
response = requests.post(
"https://service.pcibooking.net/api/payments/paycard/relay",
params={
"accessToken": "your-access-token",
"cardToken": "https://service.pcibooking.net/api/payments/paycard/555fd7b49f134b42a5dbe4d576b2e527",
"targetUri": "https://api.thirdparty.com/v1/payments",
"httpMethod": "POST"
},
headers={"Content-Type": "application/json"},
data=body
)
print(response.text)
$~Number~$, $~ExpirationM~$, $~ExpirationYYYY~$, $~CVV~$ and $~OwnerName~$ placeholders with the card data from the token before forwarding the request to api.thirdparty.com. See the full placeholder list.
To use a target profile (pre-configured replacement rules) instead of placeholders, send the card fields the profile targets with empty values. PCI Booking fills them in:
- curl
- Node.js
- Python
curl -X POST "https://service.pcibooking.net/api/payments/paycard/relay?accessToken=your-access-token&cardToken=https%3A%2F%2Fservice.pcibooking.net%2Fapi%2Fpayments%2Fpaycard%2F555fd7b49f134b42a5dbe4d576b2e527&targetUri=https%3A%2F%2Fapi.thirdparty.com%2Fv1%2Fpayments&httpMethod=POST&profileName=my-thirdparty-profile" \
-H "Content-Type: application/json" \
-d '{
"amount": 250.00,
"currency": "USD",
"card": {
"number": "",
"expMonth": "",
"expYear": "",
"cvv": "",
"holderName": ""
},
"reference": "order-98765"
}'
const params = new URLSearchParams({
accessToken: "your-access-token",
cardToken: "https://service.pcibooking.net/api/payments/paycard/555fd7b49f134b42a5dbe4d576b2e527",
targetUri: "https://api.thirdparty.com/v1/payments",
httpMethod: "POST",
profileName: "my-thirdparty-profile"
});
const response = await fetch(
`https://service.pcibooking.net/api/payments/paycard/relay?${params}`,
{
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
amount: 250.00,
currency: "USD",
card: { number: "", expMonth: "", expYear: "", cvv: "", holderName: "" },
reference: "order-98765"
})
}
);
const data = await response.text();
console.log(data);
import requests
response = requests.post(
"https://service.pcibooking.net/api/payments/paycard/relay",
params={
"accessToken": "your-access-token",
"cardToken": "https://service.pcibooking.net/api/payments/paycard/555fd7b49f134b42a5dbe4d576b2e527",
"targetUri": "https://api.thirdparty.com/v1/payments",
"httpMethod": "POST",
"profileName": "my-thirdparty-profile"
},
headers={"Content-Type": "application/json"},
json={
"amount": 250.00,
"currency": "USD",
"card": {"number": "", "expMonth": "", "expYear": "", "cvv": "", "holderName": ""},
"reference": "order-98765"
}
)
print(response.text)
Response
200 - The third-party response, relayed back as-is.Consider adding business logic based on the CVV retention policy status after a token replacement request.
The third-party response is returned as-is. The format and content depend entirely on the destination API.
Empty response body.
Authentication failed: the API key, session token or access token is missing or was not accepted.
See "Authentication and Permission Failures" on the Error Handling page.
{
"code": -125,
"message": "Bad input data",
"moreInfo": "Couldn't fetch a valid screening profile:: <profileName>",
"errorList": null
}
{
"code": -125,
"message": "Bad input data",
"moreInfo": "Invalid target Uri::",
"errorList": null
}

