Run a read-only SQL query
const url = 'https://api.sancho-wms.pl/v1/sql.query';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"sql":"example","integrationId":1}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.sancho-wms.pl/v1/sql.query \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "sql": "example", "integrationId": 1 }'Runs one SQL query against the ERP database of an integration and returns every result set it produces, in order: one per SELECT. The query must only read. Sancho sends it to the database unchanged, so the SQL login the integration’s connector uses decides what it may do. Only an integration whose connector reads the ERP’s own database serves it, and only when both the integration and the key hold sql:read, which no integration or key has by default. Write the query in that database’s own dialect, and read its schema from INFORMATION_SCHEMA.TABLES and INFORMATION_SCHEMA.COLUMNS. Each result set comes back whole. A query that runs longer than 60 seconds, or whose results together are larger than 50 MB, is refused with 400: use TOP, WHERE, fewer columns and aggregates rather than reading whole tables. Dates come back as ISO strings, bigints as strings, binary values as { "type": "Buffer", "data": [bytes] }. A column name the query repeats holds an array of every value under that name: alias the columns to keep them apart. A query the database refuses answers 400 with the database’s own message, in the server’s language.
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”object
One SQL query that only reads, in the ERP database’s own dialect.
Example generated
{ "sql": "example", "integrationId": 1}Responses
Section titled “Responses”Successful response
object
object
object
object
Example
{ "login": "readOnly"}Bad request
The error information
object
The error message
The error code
An array of issues that were responsible for the error
object
Example
{ "code": "BAD_REQUEST", "message": "Bad request", "issues": []}Unauthorized
The error information
object
The error message
The error code
An array of issues that were responsible for the error
object
Example
{ "code": "UNAUTHORIZED", "message": "Unauthorized", "issues": []}Payment required
The error information
object
The error message
The error code
An array of issues that were responsible for the error
object
Example
{ "code": "PAYMENT_REQUIRED", "message": "Payment required", "issues": []}Forbidden
The error information
object
The error message
The error code
An array of issues that were responsible for the error
object
Example
{ "code": "FORBIDDEN", "message": "Forbidden", "issues": []}Not found
The error information
object
The error message
The error code
An array of issues that were responsible for the error
object
Example
{ "code": "NOT_FOUND", "message": "Not found", "issues": []}Unprocessable content
The error information
object
The error message
The error code
An array of issues that were responsible for the error
object
Example
{ "code": "UNPROCESSABLE_CONTENT", "message": "Unprocessable content", "issues": []}Too many requests
The error information
object
The error message
The error code
An array of issues that were responsible for the error
object
Example
{ "code": "TOO_MANY_REQUESTS", "message": "Too many requests", "issues": []}Internal server error
The error information
object
The error message
The error code
An array of issues that were responsible for the error
object
Example
{ "code": "INTERNAL_SERVER_ERROR", "message": "Internal server error", "issues": []}Service unavailable
The error information
object
The error message
The error code
An array of issues that were responsible for the error
object
Example
{ "code": "SERVICE_UNAVAILABLE", "message": "Service unavailable", "issues": []}