Quickstart
Send an SMS, then receive the reply on your webhook.
1. Create an API key
In the 06 Line dashboard, open API keys and create one. It starts with 06l_ and is shown only once: store it as a
secret on your server. Never put it in a browser or a mobile app; use an ephemeral key
there.
2. Find your line
curl https://api.06line.com/v1/lines -H "Authorization: Bearer $SIXLINE_API_KEY"{ "lines": [{ "id": "line_01jbq5a3x9e2k7m4t6v8r0c1yb", "phone_number": "+33612345678", "status": "active", "online": true }] }Keep the id: every SMS and call names the line it goes out from.
3. Register a webhook
Tell 06 Line where to send incoming SMS and delivery reports:
curl -X POST https://api.06line.com/v1/webhook-endpoints \
-H "Authorization: Bearer $SIXLINE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"url": "https://example.com/webhooks/06line", "events": ["sms.received", "sms.status"]}'The answer holds a secret (whsec_…), shown once: you need it to check that requests really come from 06 Line.
Once your handler below runs, send a test event to check it.
4. Handle the webhook
import crypto from 'node:crypto';
import express from 'express';
const app = express();
app.post('/webhooks/06line', express.raw({ type: 'application/json' }), (req, res) => {
const [t, v1 = ''] = (req.get('06line-Signature') ?? '').split(',').map((part) => part.split('=')[1]);
const expected = crypto.createHmac('sha256', process.env.SIXLINE_WEBHOOK_SECRET).update(`${t}.${req.body}`).digest('hex');
const fresh = Math.abs(Date.now() / 1000 - Number(t)) < 300;
// timingSafeEqual throws on different lengths: compare them first.
const valid = v1.length === expected.length && crypto.timingSafeEqual(Buffer.from(v1), Buffer.from(expected));
if (!fresh || !valid) return res.sendStatus(400);
const event = JSON.parse(req.body);
if (event.type === 'sms.received') console.log(`${event.data.from}: ${event.data.text}`);
if (event.type === 'sms.status') console.log(`${event.data.id} is ${event.data.status}`);
res.sendStatus(200);
});
app.listen(3000);5. Send an SMS
curl -X POST https://api.06line.com/v1/sms \
-H "Authorization: Bearer $SIXLINE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"line_id": "line_01jbq5a3x9e2k7m4t6v8r0c1yb",
"to": "+33698765432",
"text": "Hello from 06 Line",
"client_ref": "quickstart-1"
}'The answer is the message with status: "queued". Your webhook then gets sms.status when it is sent and
delivered, and sms.received when the reply comes. To place calls, see Call with the SDK or Call with the API.