Start
BASE URL: https://smshgm.online/v2/api.php. Your key goes in the Authorization header.
- Get approved on your dashboard and create a key there.
- Keep the key on your server.
- The flow is list_templates, get_template, preview_document, remove_watermark.
How each step works:
- List Templates: fetch the catalogue of all documents you can create from. Search by name, country or state, then pick one by its name.
- Form fields: the form for that document. The inputs are expected, and they are used to create the document.
- Scenes: the realistic background the document sits on, like a table or a desk.
- Photos: ready portraits to put on the document, or upload your own.
- Sample: the demo of the template, to see how it looks. Sometimes the version changes the type.
- Preview: your own details on the document, with a watermark. It lets you see what you filled in before you remove the watermark.
- Remove watermark: you pay from your wallet and the clean files come back, with a zip for two-sided documents.
- Download: get a paid document again whenever you need it.
- Hosted Form: bring our existing form to your platform. Your user selects a template and enters the expected data, and our platform handles it directly.
- Wallet: your balance.
Make a request
What a call looks like, what comes back, and what an error looks like.
Request
GET https://smshgm.online/v2/api.php?action=get_wallet
Authorization: Bearer YOUR_KEY
Example Response 200
{"success":true,"data":{"balance":"197.50","currency":"USD"}}
Request
POST https://smshgm.online/v2/api.php
Authorization: Bearer YOUR_KEY
Content-Type: application/json
{"action":"preview_document","template":"Lithuania ID Card","data":{"last_name":"Shop","date_of_birth":"13/45/1995"}}
Example Response 422 bad values
{"success":false,"message":"Some values are not valid.","error_code":"INVALID_FIELDS","fields":{"date_of_birth":"Use MM/DD/YYYY","first_name":"Required"},"error_ref":"V2-AB7BE66112908DE2"}
Reading an answer:
successistruewhen the call worked, and the result is indata.- When a call fails,
messagesays what is wrong anderror_codeis its short name.fieldslists each value to fix. error_refis the reference to give the admin if the problem continues.- Every
error_codeand its fix is in Errors.
Money is text, like "2.50".
List templates GET list_templates
Every document you can create. Pick one and send its name as the template in the other calls.
Parameters
q: a word from the name, country or state. Optional.country: only this country, likeUSA. Optional.type: only this type, likeDrivers_License. Optional.
Request
GET https://smshgm.online/v2/api.php?action=list_templates
Example Response 200
{"success":true,"data":{
"templates":[
{"name":"USA FL Drivers License","country":"USA","region":"FL","type":"Drivers_License"},
{"name":"Lithuania ID Card","country":"Lithuania","type":"ID_Card"}
],
"total":2
}}
Get template GET get_template
The form of one document: the inputs you fill in to create it.
Parameters
template: the templatename, as List templates shows it.
Request
GET https://smshgm.online/v2/api.php?action=get_template&template=Lithuania%20ID%20Card
Example Response 200
{"success":true,"data":{
"name":"Lithuania ID Card","currency":"USD","price":"2.50",
"fields":[
{"id":"last_name","label":"Last name","type":"text","required":true,"example":"Shop"},
{"id":"date_of_birth","label":"Date of birth","type":"date-mask","required":true,"format":"MM/DD/YYYY","example":"01/05/1995"},
{"id":"address","label":"Address","type":"full_address","required":true,"parts":[{"id":"street","label":"Street","required":true},{"id":"city","label":"City","required":true},{"id":"state","label":"State","required":true},{"id":"zip","label":"ZIP","required":true,"format":"5 digits, like 90210"}],"example":{"street":"123 Main St","city":"Springfield","state":"FL","zip":"12345"}},
{"id":"photo","label":"Photo","type":"image","required":true,"example":"1_male"}
],
"output":{"modes":["scan","print","photo"],"default_mode":"scan"}
}}
How to fill each field type:
text: any text.select: one of theoptions.select-with-custom: one of theoptions, or your own text.date-mask:MM/DD/YYYY- Height and weight: as the field's
formatshows, like5-10and160. full_name:{"first":"Hgmtools","last":"Shop"}full_address: one value for each entry inparts, like{"street":"123 Main St","city":"Springfield","state":"FL","zip":"12345"}. ZIP and postal code rules are in USA and Canada licences and IDs.checkbox:trueimage: a photo name from Photos, or theimagethat Upload your own photo gives back.signature:{"text":"Hgmtools"}with up to 8 characters, or theimagefrom Signature. Optional: when it is left out, the first name is written.
Every example is a valid value you can send as it is.
If it fails:
- 404
TEMPLATE_NOT_FOUND: no template has thatname. Copy one from List templates. - 422
INVALID_TEMPLATE: thetemplateis empty or is not a name. Copy one from List templates. - 422
TEMPLATE_UNAVAILABLE: this template cannot be used through the API right now. Use another one.
USA and Canada licences and IDs
What these documents accept.
- State or province: the 2-letter code. USA:
FL,TX,NYand the rest. Canada:AB,BC,MB,NB,NL,NS,NT,NU,ON,PE,QC,SK,YT. - ZIP or postal code: USA is 5 digits, like
90210. Canada is 6 characters, likeK1A 0B1. - Dates:
MM/DD/YYYY. They must be real dates, the birth date in the past and the expiry after the issue date. - Sex: one of the field's
options, likeMorF. - Height and weight: as each field's
formatsays, like5-10and160. - Required: first and last name, the three dates, sex, eye colour, height, street, city, state, ZIP or postal code, licence number and the document discriminator (
dd).
Signature POST upload_image
Turns a photo of your handwritten signature into a transparent PNG, at most 520 x 180.
Parameters
kind:signatureimage: the photo as a data URL, likedata:image/jpeg;base64,.... JPEG, PNG or WebP, up to 8 MB.
Request
{"action":"upload_image","kind":"signature","image":"data:image/jpeg;base64,/9j/4AAQ..."}
Example Response 200
{"success":true,"data":{"kind":"signature","image":"data:image/png;base64,iVBORw0KGgo...","width":520,"height":160,"background_removed":true}}
Put the returned image in the signature field: {"image":"data:image/png;base64,..."}.
If it fails:
- 422
INVALID_IMAGE: the photo is empty, unreadable or over 8 MB, or no signature was found in it.messagesays which. Send a clearer photo.
Scenes GET list_scenes
The realistic background the document sits on, like a table or a desk.
Parameters
template: the templatename, as List templates shows it.q: a word from the scene name. Optional.
Request
GET https://smshgm.online/v2/api.php?action=list_scenes&template=Lithuania%20ID%20Card
Example Response 200
{"success":true,"data":{"scenes":[{"id":"scene_01","name":"01"},{"id":"scene_02","name":"02"}],"total":2}}
The output_type decides how a scene is used:
scan: the document on a scene. The default scene is used when you send none.print: the document plain, or on a scene when you send one.photo: the document plain, with no scene.
One scene GET get_scene
One scene image, by its name.
Parameters
template: the templatename, as List templates shows it.scene: the scenename.
Request
GET https://smshgm.online/v2/api.php?action=get_scene&template=Lithuania%20ID%20Card&scene=01
Example Response 200
{"success":true,"data":{"scene_id":"scene_01","name":"01","mime":"image/jpeg","data":"/9j/4AAQ..."}}
If it fails:
- 404
UNKNOWN_SCENE: the template has no scene with that name. Use a name from Scenes.
Photos GET list_photos
Ready portraits to put on the document.
Parameters
gender:maleorfemale. Optional.
Request
GET https://smshgm.online/v2/api.php?action=list_photos
Example Response 200
{"success":true,"data":{"photos":[{"id":"1_male","name":"1_male","gender":"male"},{"id":"2_female","name":"2_female","gender":"female"}],"total":2}}
One photo GET get_photo
One ready portrait, by its name.
Parameters
photo: the photoname.
Request
GET https://smshgm.online/v2/api.php?action=get_photo&photo=1_male
Example Response 200
{"success":true,"data":{"id":"1_male","name":"1_male","gender":"male","mime":"image/png","data":"iVBORw0KGgo..."}}
If it fails:
- 404
PHOTO_NOT_FOUND: no photo has that name. Use a name from Photos. - 422
INVALID_PHOTO: thephotois empty or too long. Use a name from Photos.
Upload your own photo POST upload_image
Use your own portrait. The background is removed for you.
Parameters
kind:photoimage: the portrait as a data URL, likedata:image/jpeg;base64,.... JPEG, PNG or WebP, up to 8 MB.
Request
{"action":"upload_image","kind":"photo","image":"data:image/jpeg;base64,/9j/4AAQ..."}
Example Response 200
{"success":true,"data":{"kind":"photo","image":"data:image/png;base64,iVBORw0KGgo...","width":900,"height":1200,"background_removed":true,"already_transparent":false}}
Use the returned image as the value of a photo field. A photo that is already transparent comes back as it is.
If it fails:
- 422
INVALID_IMAGE: the photo is empty, unreadable or over 8 MB.messagesays which. Send another one.
Sample GET sample_preview
The sample of a template. It is the same every time, so you can keep it.
Parameters
template: the templatename, as List templates shows it.
Request
GET https://smshgm.online/v2/api.php?action=sample_preview&template=Lithuania%20ID%20Card
Example Response 200
{"success":true,"data":{"images":[{"side":"both","mime":"image/jpeg","data":"iVBORw0KGgo..."}]}}
If it fails:
- 404
TEMPLATE_NOT_FOUND: no template has thatname. Copy one from List templates. - 429
DAILY_LIMIT: the samples allowed today are used up. Try again after 00:00 UTC.
Preview POST preview_document
Your details on the document, with a watermark, so you can check it before you pay. Free, and valid for 10 minutes. The preview is smaller than the paid file.
Parameters
template: the templatename, as List templates shows it.data: one value for each field, named by itsid. Required fields must be there.output_type:scan,printorphoto. Optional: the default isscan.scene: a scenenamefrom Scenes. Optional.
Request
{
"action": "preview_document",
"template": "Lithuania ID Card",
"data": {"first_name": "Hgmtools", "last_name": "Shop", "date_of_birth": "01/05/1995", "photo": "1_male", "signature": {"text": "Hgmtools"}},
"output_type": "scan",
"scene": "01"
}
Example Response 200
{"success":true,"data":{"preview_id":"pv_5c1e0d4a9b...","price":"2.50","currency":"USD","expires_at":"2026-01-01T12:10:00+00:00","images":[{"side":"both","mime":"image/jpeg","data":"iVBORw0KGgo..."}]}}
The answer gives the preview_id and the price. Send both to Remove watermark.
If it fails:
- 422
INVALID_FIELDS:fieldslists each wrong or missing value and what it needs. Fix them and send again. - 422
INVALID_OUTPUT:output_typemust bescan,printorphoto. - 422
UNKNOWN_SCENE: the template has no scene with that name. Use a name from Scenes. - 422
PHOTO_HAS_NO_SCENE: aphotooutput takes no scene. Leavesceneout. - 413
IMAGE_BUDGET: the images indataare too large together. Send smaller ones. - 429
TOO_MANY_ACTIVE_PREVIEWS: too many previews are open. They expire after 10 minutes. - 429
DAILY_LIMIT: the previews allowed today are used up. Try again after 00:00 UTC.
Remove watermark POST remove_watermark
Pays from your wallet and gives you the clean files.
Parameters
preview_id: thepreview_idfrom the Preview answer.price: thepricefrom the same answer, like"2.50".
Request
{"action":"remove_watermark","preview_id":"pv_5c1e0d4a9b...","price":"2.50"}
Example Response 200
{"success":true,"data":{"paid":true,"images":[{"side":"front","name":"IMG_1790000000_12_1.jpg","mime":"image/jpeg","data":"/9j/4AAQ..."},{"side":"back","name":"IMG_1790000000_12_2.jpg","mime":"image/jpeg","data":"/9j/4AAQ..."}],"zip":{"name":"IMG_11242675.zip","mime":"application/zip","data":"UEsDBBQ..."}}}
- A two-sided document comes back as
frontandback, plus onezipwith both. - On a scene the files are JPEGs with phone camera details. With no scene they are transparent PNGs.
- Each preview is charged once. If a call times out, send the same request again and you get the same files.
If it fails:
- 402
INSUFFICIENT_FUNDS: the wallet is below the price. Add funds, then send the same request again. - 409
PRICE_CHANGED: the price is not the one you were shown. Nothing is charged. Preview again. - 409
TEMPLATE_CHANGED: the template was edited after your preview. Preview again. - 410
PREVIEW_EXPIRED: the preview is older than 10 minutes. Preview again. - 404
PREVIEW_NOT_FOUND: no preview has thatpreview_id. Copy it from the Preview answer. - 422
INVALID_PREVIEW: thepreview_idis not valid. Copy it from the Preview answer. - 422
INVALID_PRICE: send thepriceas text, like"2.50".
Download POST recover_document
Gets a paid document again, by its preview_id. It is never charged twice.
Parameters
preview_id: thepreview_idyou paid for. Keep it with your records.
Request
{"action":"recover_document","preview_id":"pv_5c1e0d4a9b..."}
Example Response 200
{"success":true,"data":{"paid":true,"images":[{"side":"front","name":"IMG_1790000000_12_1.jpg","mime":"image/jpeg","data":"/9j/4AAQ..."},{"side":"back","name":"IMG_1790000000_12_2.jpg","mime":"image/jpeg","data":"/9j/4AAQ..."}],"zip":{"name":"IMG_11242675.zip","mime":"application/zip","data":"UEsDBBQ..."}}}
If it fails:
- 404
PAID_ORDER_NOT_FOUND: that preview was never paid. - 410
DELIVERY_EXPIRED: the paid file is no longer kept.
Wallet GET get_wallet
Your balance.
Request
GET https://smshgm.online/v2/api.php?action=get_wallet
Example Response 200
{"success":true,"data":{"balance":"197.50","currency":"USD"}}
Hosted form POST editor_session
Our ready-made form, on your own platform. Your users pick a template and fill in the data, and we handle the rest.
Parameters
template: the templatename, as List templates shows it.origin: the address of the page that shows the form, likehttps://yourapp.com. Add it under Allowed sites on your dashboard first.theme:site,darkorlight. Optional.
Request
{"action":"editor_session","template":"Lithuania ID Card","origin":"https://yourapp.com"}
Example Response 200
{"success":true,"data":{"method":"POST","path":"/v2/editor/","ticket":"et_...","expires_at":"2026-01-01T12:02:00+00:00"}}
The ticket lasts 2 minutes, so give the answer to the form right away:
<iframe id="form" style="width:100%;height:900px;border:0"></iframe>
<script src="https://smshgm.online/v2/client.js"></script>
<script>
TemplateForms.mount(document.getElementById('form'), SESSION_FROM_YOUR_SERVER, {
preview: async (payload) => (await fetch('/preview', {method:'POST', body:JSON.stringify(payload)})).json(),
purchase: async (order) => (await fetch('/buy', {method:'POST', body:JSON.stringify(order)})).json()
});
</script>
/preview and /buy are routes on your server. Each one forwards the payload it receives to https://smshgm.online/v2/api.php with your key, and returns the answer.
If it fails:
- 403
ORIGIN_NOT_APPROVED: theoriginis not under Allowed sites on your dashboard. Add it there. - 422
INVALID_ORIGIN: theoriginmust look likehttps://yourapp.com. - 422
INVALID_THEME:thememust besite,darkorlight. - 403
INVALID_EDITOR_SESSION: the ticket has expired, or the form is on another address than theorigin. Sendeditor_sessionagain. - 429
TOO_MANY_FORM_SESSIONS: too many forms are open. Try again shortly.
Full example
List, read, preview and pay from a server. Put your key in TEMPLATE_API_KEY.
PHP
<?php
$API = 'https://smshgm.online/v2/api.php';
function send($url, $post = null) {
$head = ['Authorization: Bearer ' . getenv('TEMPLATE_API_KEY')];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
if ($post !== null) {
$head[] = 'Content-Type: application/json';
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($post));
}
curl_setopt($ch, CURLOPT_HTTPHEADER, $head);
$r = json_decode(curl_exec($ch), true);
if (empty($r['success'])) die(json_encode($r) . "\n");
return $r['data'];
}
function api_get($query) { global $API; return send($API . '?' . http_build_query($query)); }
function api_post($body) { global $API; return send($API, $body); }
$tpl = api_get(['action' => 'list_templates'])['templates'][0]['name'];
$form = api_get(['action' => 'get_template', 'template' => $tpl]);
$data = [];
foreach ($form['fields'] as $f) if (isset($f['example'])) $data[$f['id']] = $f['example'];
$pv = api_post(['action' => 'preview_document', 'template' => $tpl, 'data' => $data]);
$paid = api_post(['action' => 'remove_watermark', 'preview_id' => $pv['preview_id'], 'price' => $pv['price']]);
file_put_contents($paid['images'][0]['name'], base64_decode($paid['images'][0]['data']));
Python
import base64, os, requests
API = "https://smshgm.online/v2/api.php"
HEAD = {"Authorization": "Bearer " + os.environ["TEMPLATE_API_KEY"]}
def read(r):
j = r.json()
if not j.get("success"):
raise SystemExit(j)
return j["data"]
def get(params):
return read(requests.get(API, headers=HEAD, params=params, timeout=120))
def post(body):
return read(requests.post(API, headers=HEAD, json=body, timeout=120))
tpl = get({"action": "list_templates"})["templates"][0]["name"]
form = get({"action": "get_template", "template": tpl})
data = {f["id"]: f["example"] for f in form["fields"] if "example" in f}
pv = post({"action": "preview_document", "template": tpl, "data": data})
paid = post({"action": "remove_watermark", "preview_id": pv["preview_id"], "price": pv["price"]})
open(paid["images"][0]["name"], "wb").write(base64.b64decode(paid["images"][0]["data"]))
Node.js
const API = "https://smshgm.online/v2/api.php";
const HEAD = {"Authorization": "Bearer " + process.env.TEMPLATE_API_KEY};
async function send(url, options) {
const r = await fetch(url, options);
const j = await r.json();
if (!j.success) throw new Error(JSON.stringify(j));
return j.data;
}
const get = (query) => send(API + "?" + new URLSearchParams(query), {headers: HEAD});
const post = (body) => send(API, {
method: "POST",
headers: {...HEAD, "Content-Type": "application/json"},
body: JSON.stringify(body),
});
const tpl = (await get({action: "list_templates"})).templates[0].name;
const form = await get({action: "get_template", template: tpl});
const data = {};
for (const f of form.fields) if (f.example !== undefined) data[f.id] = f.example;
const pv = await post({action: "preview_document", template: tpl, data});
const paid = await post({action: "remove_watermark", preview_id: pv.preview_id, price: pv.price});
await (await import("node:fs/promises")).writeFile(paid.images[0].name, Buffer.from(paid.images[0].data, "base64"));
Errors
Find the status and error_code of your answer below.
- 400
INVALID_PARAMETERS: a GET option is repeated, unknown or too long. Send only the options listed for the call, once each. - 400
INVALID_JSON: the body is not valid JSON. Check the quotes and commas. - 400
DUPLICATE_JSON_KEY: the body repeats a key. Send each key once. - 400
UNKNOWN_ACTION: theactionis not a call in this guide. Check the spelling. - 401
INVALID_KEY: the key is missing, wrong or deleted. Send it asAuthorization: Bearer YOUR_KEY, or create a new one on your dashboard. - 402
INSUFFICIENT_FUNDS: the wallet is below the price. Add funds, then send the request again. - 403
NOT_PERMITTED: this key may not do that, for example it has no template access yet. Ask the admin. - 403
INACTIVE_OR_UNAUTHORIZED: this account cannot use the API right now. Ask the admin. - 403
SITE_DEPOSIT_REQUIRED: a deposit is needed first. Make it, then send the request again. - 403
ORIGIN_NOT_APPROVED: theoriginis not allowed for the hosted form. Add it under Allowed sites on your dashboard. - 403
INVALID_EDITOR_SESSION: the form ticket has expired, or the form is on another address than theorigin. Sendeditor_sessionagain. - 403
HTTPS_REQUIRED: call the base URL withhttps://. - 404
NOT_FOUND: there is no such call. Check the URL. - 404
TEMPLATE_NOT_FOUND: no template has thatname. Use one from List templates. - 404
UNKNOWN_SCENE: the template has no scene with that name. Use a name from Scenes. - 404
PHOTO_NOT_FOUND: no photo has that name. Use a name from Photos. - 404
PREVIEW_NOT_FOUND: no preview has thatpreview_id. Copy it from the Preview answer. - 404
PAID_ORDER_NOT_FOUND: that preview was never paid. - 405
METHOD_NOT_ALLOWED: the call needs the other method. Use GET or POST as its section shows. - 409
PRICE_CHANGED: the price changed since the preview. Nothing is charged. Preview again. - 409
TEMPLATE_CHANGED: the template changed since the preview. Get the template again, then preview again. - 409
ORDER_CONFLICT: this payment clashes with an earlier one. Preview again. - 410
PREVIEW_EXPIRED: a preview lasts 10 minutes. Preview again. - 410
DELIVERY_EXPIRED: the paid file is no longer kept. - 413
TOO_LARGE: the request is over the size limit. Send less data. - 413
IMAGE_TOO_LARGE: an image is too large. Send a smaller one. - 413
IMAGE_BUDGET: the images together are too large. Send fewer or smaller images. - 415
JSON_REQUIRED: send the headerContent-Type: application/json. - 422
INVALID_REQUEST: a key is missing, misspelled or has the wrong type.messagenames it. - 422
INVALID_FIELDS: somedatavalues are wrong.fieldslists each one, and its message says what it needs, likeRequiredorUse MM/DD/YYYY. - 422
INVALID_TEMPLATE: thetemplateis empty or is not a name. Copy one from List templates. - 422
INVALID_PHOTO: thephotois empty or too long. Use a name from Photos. - 422
INVALID_PRICE: send the price as text, like"2.50". - 422
INVALID_PREVIEW: thepreview_idis not valid. Copy it from the Preview answer. - 422
INVALID_OUTPUT:output_typemust bescan,printorphoto. - 422
UNKNOWN_SCENE: the template has no scene with that name. Use a name from Scenes. - 422
PHOTO_HAS_NO_SCENE: aphotooutput takes no scene. Leavesceneout. - 422
INVALID_IMAGE: the image is empty, unreadable or over 8 MB.messagesays which. - 422
TEMPLATE_UNAVAILABLE: this template cannot be used through the API right now. Use another one. - 422
FORM_TOO_LARGE: this template's form is too large to be used. Use another template. - 422
INVALID_ORIGIN: theoriginmust look likehttps://yourapp.com. - 422
INVALID_THEME:thememust besite,darkorlight. - 429
RATE_LIMITED: too many calls in a minute. Wait a minute, then send again. - 429
DAILY_LIMIT: the daily limit for this call is used up. It resets at 00:00 UTC. - 403
ACCOUNT_PAUSED: the account is paused. Contact us to continue. - 429
TOO_MANY_ACTIVE_PREVIEWS: too many previews are open. Wait for them to expire. - 429
TOO_MANY_FORM_SESSIONS: too many forms are open. Try again shortly. - 503
SERVICE_DISABLED: the API is switched off. Try later. - 503
SITE_MAINTENANCE: the website is in maintenance. Try later. - 503
BUSY_RETRY: busy. Send the same request again in a moment. - 503
UNAVAILABLE: the call could not finish. Send it again. If it repeats, give the admin theerror_ref.
