🎉 Unlimited Free KYC - Forever!!

Auth + Data
Data API Reference
Create Session

Creating a Data Transfer Session

After obtaining a valid client access token, you can call the /session endpoint to create a new data transfer session.

  • Base URL: https://apx.didit.me
  • Endpoint: /auth/v2/session
  • Method: POST
  • Authentication: Client Token (Bearer Token)
⚠ī¸

Ensure you are using the correct Base URL for this endpoint to avoid connectivity issues.

Request

To create a session programmatically, follow these steps:

Authenticate

To obtain the access_token, refer to the Authentication documentation page.

ℹī¸

The access_token is valid for a limited time, so you do not need to authenticate for every request until the token expires.

Select Desired Parameters

  • scope: The data scopes you're requesting access to. These should be space-separated. You can find a list of available scopes here.

    • Example: "pictures names email"
  • vendor_data: Unique identifier or data for the vendor, typically the uuid of the user trying to verify.

Create Session Request

POST /auth/v2/session HTTP/1.1
Host: auth.didit.me
Content-Type: application/json
Authorization: Bearer {access_token}
 
{
  "scope": "pictures names email",
  "vendor_data": "optional-vendor-data"
}

Response

Returns session details including session_id, session_token, and url. The session_id should be linked to your user in your User model, and you should generate a QR code containing the url for your user to scan.

For easy integration, use onSessionIdResolver hook in the SDK and make a call to your backend, and return the session_id to automatically handle the QR code generation with the session information. Check Yoti example (opens in a new tab) for more information.

Example Response

{
  "session_id": "unique-session-identifier",
  "session_token": "your-session-token",
  "url": "https://app.didit.me/authorize/{session_token}",
}

Code Example:

const createSession = async (
  scope: string,
  vendorData?: string
) => {
  const url = `${BASE_URL}/auth/v2/session`;
  const token = await getClientToken();
 
  if (!token) {
    console.error('Error fetching client token');
  } else {
    const body = {
      scope: scope,
      vendor_data: vendorData
    };
 
    const requestOptions = {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
        Authorization: `Bearer ${token.access_token}`,
      },
      body: JSON.stringify(body),
    };
 
    try {
      const response = await fetch(url, requestOptions);
 
      const data = await response.json();
 
      if (response.status === 201 && data) {
        return data;
      } else {
        console.error('Error creating session:', data.message);
        throw new Error(data.message);
      }
    } catch (error) {
      console.error('Network error:', error);
      throw error;
    }
  }
};