Record the postcode the user selected
curl --request POST \
--url https://platform.postcode.gov.ng/v1/widget/selected \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"selection": {
"version": 1,
"postcode": "FC02A09DB09",
"formatted": "FC-02-A09-DB-09",
"level": 3,
"segments": {
"state": "FC",
"lga": "02",
"district": "A09",
"area": "DB",
"unit": "09"
},
"names": {
"state": "<string>",
"lga": "<string>",
"district": "<string>",
"area": "<string>"
},
"latitude": 123,
"longitude": 123,
"label": "<string>"
}
}
'import requests
url = "https://platform.postcode.gov.ng/v1/widget/selected"
payload = { "selection": {
"version": 1,
"postcode": "FC02A09DB09",
"formatted": "FC-02-A09-DB-09",
"level": 3,
"segments": {
"state": "FC",
"lga": "02",
"district": "A09",
"area": "DB",
"unit": "09"
},
"names": {
"state": "<string>",
"lga": "<string>",
"district": "<string>",
"area": "<string>"
},
"latitude": 123,
"longitude": 123,
"label": "<string>"
} }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
selection: {
version: 1,
postcode: 'FC02A09DB09',
formatted: 'FC-02-A09-DB-09',
level: 3,
segments: {state: 'FC', lga: '02', district: 'A09', area: 'DB', unit: '09'},
names: {state: '<string>', lga: '<string>', district: '<string>', area: '<string>'},
latitude: 123,
longitude: 123,
label: '<string>'
}
})
};
fetch('https://platform.postcode.gov.ng/v1/widget/selected', 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://platform.postcode.gov.ng/v1/widget/selected",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'selection' => [
'version' => 1,
'postcode' => 'FC02A09DB09',
'formatted' => 'FC-02-A09-DB-09',
'level' => 3,
'segments' => [
'state' => 'FC',
'lga' => '02',
'district' => 'A09',
'area' => 'DB',
'unit' => '09'
],
'names' => [
'state' => '<string>',
'lga' => '<string>',
'district' => '<string>',
'area' => '<string>'
],
'latitude' => 123,
'longitude' => 123,
'label' => '<string>'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://platform.postcode.gov.ng/v1/widget/selected"
payload := strings.NewReader("{\n \"selection\": {\n \"version\": 1,\n \"postcode\": \"FC02A09DB09\",\n \"formatted\": \"FC-02-A09-DB-09\",\n \"level\": 3,\n \"segments\": {\n \"state\": \"FC\",\n \"lga\": \"02\",\n \"district\": \"A09\",\n \"area\": \"DB\",\n \"unit\": \"09\"\n },\n \"names\": {\n \"state\": \"<string>\",\n \"lga\": \"<string>\",\n \"district\": \"<string>\",\n \"area\": \"<string>\"\n },\n \"latitude\": 123,\n \"longitude\": 123,\n \"label\": \"<string>\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://platform.postcode.gov.ng/v1/widget/selected")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"selection\": {\n \"version\": 1,\n \"postcode\": \"FC02A09DB09\",\n \"formatted\": \"FC-02-A09-DB-09\",\n \"level\": 3,\n \"segments\": {\n \"state\": \"FC\",\n \"lga\": \"02\",\n \"district\": \"A09\",\n \"area\": \"DB\",\n \"unit\": \"09\"\n },\n \"names\": {\n \"state\": \"<string>\",\n \"lga\": \"<string>\",\n \"district\": \"<string>\",\n \"area\": \"<string>\"\n },\n \"latitude\": 123,\n \"longitude\": 123,\n \"label\": \"<string>\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://platform.postcode.gov.ng/v1/widget/selected")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"selection\": {\n \"version\": 1,\n \"postcode\": \"FC02A09DB09\",\n \"formatted\": \"FC-02-A09-DB-09\",\n \"level\": 3,\n \"segments\": {\n \"state\": \"FC\",\n \"lga\": \"02\",\n \"district\": \"A09\",\n \"area\": \"DB\",\n \"unit\": \"09\"\n },\n \"names\": {\n \"state\": \"<string>\",\n \"lga\": \"<string>\",\n \"district\": \"<string>\",\n \"area\": \"<string>\"\n },\n \"latitude\": 123,\n \"longitude\": 123,\n \"label\": \"<string>\"\n }\n}"
response = http.request(request)
puts response.read_bodyWidget
Record the postcode the user selected
Fire-and-forget analytics for the host integration. Served by the platform host, not the gateway.
POST
/
v1
/
widget
/
selected
Record the postcode the user selected
curl --request POST \
--url https://platform.postcode.gov.ng/v1/widget/selected \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"selection": {
"version": 1,
"postcode": "FC02A09DB09",
"formatted": "FC-02-A09-DB-09",
"level": 3,
"segments": {
"state": "FC",
"lga": "02",
"district": "A09",
"area": "DB",
"unit": "09"
},
"names": {
"state": "<string>",
"lga": "<string>",
"district": "<string>",
"area": "<string>"
},
"latitude": 123,
"longitude": 123,
"label": "<string>"
}
}
'import requests
url = "https://platform.postcode.gov.ng/v1/widget/selected"
payload = { "selection": {
"version": 1,
"postcode": "FC02A09DB09",
"formatted": "FC-02-A09-DB-09",
"level": 3,
"segments": {
"state": "FC",
"lga": "02",
"district": "A09",
"area": "DB",
"unit": "09"
},
"names": {
"state": "<string>",
"lga": "<string>",
"district": "<string>",
"area": "<string>"
},
"latitude": 123,
"longitude": 123,
"label": "<string>"
} }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
selection: {
version: 1,
postcode: 'FC02A09DB09',
formatted: 'FC-02-A09-DB-09',
level: 3,
segments: {state: 'FC', lga: '02', district: 'A09', area: 'DB', unit: '09'},
names: {state: '<string>', lga: '<string>', district: '<string>', area: '<string>'},
latitude: 123,
longitude: 123,
label: '<string>'
}
})
};
fetch('https://platform.postcode.gov.ng/v1/widget/selected', 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://platform.postcode.gov.ng/v1/widget/selected",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'selection' => [
'version' => 1,
'postcode' => 'FC02A09DB09',
'formatted' => 'FC-02-A09-DB-09',
'level' => 3,
'segments' => [
'state' => 'FC',
'lga' => '02',
'district' => 'A09',
'area' => 'DB',
'unit' => '09'
],
'names' => [
'state' => '<string>',
'lga' => '<string>',
'district' => '<string>',
'area' => '<string>'
],
'latitude' => 123,
'longitude' => 123,
'label' => '<string>'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://platform.postcode.gov.ng/v1/widget/selected"
payload := strings.NewReader("{\n \"selection\": {\n \"version\": 1,\n \"postcode\": \"FC02A09DB09\",\n \"formatted\": \"FC-02-A09-DB-09\",\n \"level\": 3,\n \"segments\": {\n \"state\": \"FC\",\n \"lga\": \"02\",\n \"district\": \"A09\",\n \"area\": \"DB\",\n \"unit\": \"09\"\n },\n \"names\": {\n \"state\": \"<string>\",\n \"lga\": \"<string>\",\n \"district\": \"<string>\",\n \"area\": \"<string>\"\n },\n \"latitude\": 123,\n \"longitude\": 123,\n \"label\": \"<string>\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://platform.postcode.gov.ng/v1/widget/selected")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"selection\": {\n \"version\": 1,\n \"postcode\": \"FC02A09DB09\",\n \"formatted\": \"FC-02-A09-DB-09\",\n \"level\": 3,\n \"segments\": {\n \"state\": \"FC\",\n \"lga\": \"02\",\n \"district\": \"A09\",\n \"area\": \"DB\",\n \"unit\": \"09\"\n },\n \"names\": {\n \"state\": \"<string>\",\n \"lga\": \"<string>\",\n \"district\": \"<string>\",\n \"area\": \"<string>\"\n },\n \"latitude\": 123,\n \"longitude\": 123,\n \"label\": \"<string>\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://platform.postcode.gov.ng/v1/widget/selected")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"selection\": {\n \"version\": 1,\n \"postcode\": \"FC02A09DB09\",\n \"formatted\": \"FC-02-A09-DB-09\",\n \"level\": 3,\n \"segments\": {\n \"state\": \"FC\",\n \"lga\": \"02\",\n \"district\": \"A09\",\n \"area\": \"DB\",\n \"unit\": \"09\"\n },\n \"names\": {\n \"state\": \"<string>\",\n \"lga\": \"<string>\",\n \"district\": \"<string>\",\n \"area\": \"<string>\"\n },\n \"latitude\": 123,\n \"longitude\": 123,\n \"label\": \"<string>\"\n }\n}"
response = http.request(request)
puts response.read_bodyAuthorizations
Short-lived widget session JWT from POST /v1/widget/session
Body
application/json
The single cross-platform payload every widget SDK delivers to its host app on selection (version 1). segments/names fields below the selection's level are null; latitude/longitude appear only when the key's lookup level permits point geometry.
Show child attributes
Show child attributes
Response
Recorded
⌘I

