Collect and Send Data
Collect and Send Data
Send Data to Your Server via VGS Proxy
Send Data
// - `path` (string, optional): The API endpoint path.
// - `method` (string, optional): The HTTP method (default is POST).
// - `extraData` (Record<string, any>, optional): Additional data to send.
// - `customRequestStructure` (Record<string, any>, optional): JSON pattern, applies a custom structure template to the collected sensitive data.
// - Returns a Promise that resolves with the server response, or rejects with a validation error./
submit(path: string = '', method: string = 'POST', extraData: Record<string, any> = {}, customRequestStructure?: Record<string, any>): Promise<{ status: number; response: any }>Code example
// Setup your vauldId and environment
const collector = new VGSCollect('vaultId', 'sandbox');
try {
const { status, response } = await collector.submit('/post', 'POST');
if (response.ok) {
try {
const responseBody = await response.json();
const json = JSON.stringify(responseBody, null, 2);
console.log('Success:', json);
} catch (error) {
console.warn(
'Error parsing response body. Body can be empty or your <vaultId> is wrong!',
error
);
}
} else {
console.warn(`Server responded with error: ${status}\n${response}`);
if (status === 400) {
console.error('Bad request! Check your VGSCollect config and input.');
} else if (status === 500) {
console.error('Server issue! Try again later.');
}
}
} catch (error) {
if (error instanceof VGSError) {
switch (error.code) {
case VGSErrorCode.InputDataIsNotValid:
for (const fieldName in error.details) {
console.error(
`Not valid fieldName: ${fieldName}: ${error.details[fieldName].join(', ')}`
);
}
break;
default:
console.error('VGSError:', error.code, error.message);
}
} else {
console.error('Network or unexpected error:', error);
}
}Tokenize data
Tokenization API
Code example
Tokenization Parameters
Tokenization format
Field Type
Default Format
Tokenization storage
Field Type
Default Storage
Code example
Migrating from Vault API v1 to v2
Last updated

