Background supergraphic

NPWP Sessions

A session is required when you want integrate our Prebuilt Web Pages into your product/platform. It contains the unique URL for your user to access the prebuilt web pages.

NPWP Sessions Object

  • Name
    status
    Type
    string
    Description

    The status of the session. Possible values are:

    1. PENDING when the user has not finished the session.
    2. FINISHED when the user has finished the session.
  • Name
    expired
    Type
    number
    Description

    Number (in milliseconds since epoch) indicating the session expiration.

  • Name
    url
    Type
    string
    Description

    The URL to access the session.

  • Name
    success_url
    Type
    string
    Description

    The URL the user will be directed to after the session is successful.

  • Name
    cancel_url
    Type
    string
    Description

    If set, the prebuilt web pages will show a back button and users will be directed to this URL if they decide to cancel.

  • Name
    result
    Type
    string
    Description

    Contains the result. When the session has not been finished. The result will be null.


POST/ocr/v1/npwp-sessions

Create a NPWP Session

Create a NPWP session. By default, a session will automatically expire after 24 hours.

Required parameter

  • Name
    success_url
    Type
    string
    Description

    When the session is successful, GLAIR will redirect to this URL. When GLAIR redirects your user to success_url, GLAIR will append sid to the query parameter. Use this sid to retrieve the result if necessary.

Optional parameter

  • Name
    cancel_url
    Type
    string
    Description

    If set, GLAIR will show a back button on the prebuilt-ui and your user will be directed to this URL when the button is clicked.

Sample Request

POST
/ocr/v1/npwp-sessions
1
2
3
4
5
6
7
8
import { Vision } from '@glair/vision'; const vision = new Vision({ apiKey: 'api-key', username: 'username', password: 'password' }); await vision.ocr.npwpSessions.create({ success_url: `SUCCESS_URL`, cancel_url: `CANCEL_URL` });

Sample Response

1
2
3
4
5
6
{ "status": "PENDING", "success_url": "https://yourdomain.com?success=true", "cancel_url": "https://yourdomain.com?cancel=true", "url": "https://vision.glair.ai/npwp/eyJhbgc9asdalkja" }

GET/ocr/v1/npwp-sessions/:sid

Retrieve a NPWP Session

Create a NPWP session. By default, a session will automatically expire after 24 hours.

Required parameter

  • Name
    sid
    Type
    string
    Description

    The session ID you want to retrieve.

Sample Request

GET
/ocr/v1/npwp-sessions/:sid
1
2
3
4
5
6
7
8
9
import { Vision } from '@glair/vision'; const vision = new Vision({ apiKey: 'api-key', username: 'username', password: 'password', }); await vision.ocr.npwpSessions.retrieve({ sid: 'SID' });

Sample Response

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
{ "status": "FINISHED", "expired": 1678247333160, "url": "https://vision.glair.ai/ktp/eyJhbgc9asdalkja", "success_url": "https://yourdomain.com?success=true", "cancel_url": "https://yourdomain.com?cancel=true", "result": { "images": { "captured": "/9j/4AAQSkZJRgABAQAAAQABAAD/...", }, "read": { "alamat": { "confidence": 97, "value": "JL. PELELANGAN IKAN NO. RT.002 RW.002\nKEL.MA,JAKERTA KEC.BALONGAN\nINDRAMAYU, JAWA BARAT" }, "nama": { "confidence": 99, "value": "BERSATU" }, "nik": { "confidence": 0, "value": "" }, "noNpwp": { "confidence": 99, "value": "70.943.997.0-437.000" } }, "form": { "alamat": "JL. PELELANGAN IKAN NO. RT.002 RW.002\nKEL.MA,JAKERTA KEC.BALONGAN\nINDRAMAYU, JAWA BARAT", "nama": "BERSATU", "nik": "", "noNpwp": "70.943.997.0-437.000" }, "reason": "File Successfully Read", "status": "SUCCESS" } }