### Clone Truv Quickstart Repository and Set Up Environment (Docker) Source: https://docs.truv.com/docs/quickstart-guide This snippet explains how to clone the Truv Quickstart repository, navigate to the Python directory, copy an example environment file to `.env`, and update it with the user's Client ID and Sandbox Access key. This is the initial setup for using Truv's API within a Dockerized Python environment. ```coffeescript # Clone the Quickstart repository git clone https://github.com/citadelid/quickstart.git # Open Quickstart in your coding language cd quickstart/python # Copy the .env.example file to a new file in the same directory and name it .env. cp .env.example .env # Update the values adding in the your Client ID and Sandbox Access key. #API_CLIENT_ID= #API_SECRET= ``` -------------------------------- ### Clone Truv Quickstart Repository and Set Up Docker Environment (Python) Source: https://docs.truv.com/docs/quickstart-1 This snippet details cloning the Truv Quickstart repository and setting up the Python environment using Docker. It involves copying an example environment file, updating API credentials and product types, and running a Docker-based setup script. Dependencies include Git, Docker, and Python. The output is a Python development environment running in Docker. ```shell # Clone the Quickstart repository git clone https://github.com/citadelid/quickstart.git # Open Quickstart in your coding language cd quickstart/python # Copy the .env.example file to a new file in the same directory and name it .env. cp .env.example .env # Update the values adding in the your Client ID and Sandbox Access key. #API_CLIENT_ID= #API_SECRET= # Uncomment the line with API_PRODUCT_TYPE that you want to use #API_PRODUCT_TYPE=employment #Run the make script for your coding language make python_docker ``` -------------------------------- ### Clone Truv Quickstart Repository and Set Up Local Environment (Unix) Source: https://docs.truv.com/docs/quickstart-1 This snippet outlines the steps to clone the Truv Quickstart repository, set up the local environment using a Makefile, and configure API credentials and product types for local development. It requires Git and Make to be installed. The output is a configured local development environment. ```shell # Clone the Quickstart repository git clone https://github.com/truvhq/quickstart.git # Open Quickstart cd quickstart # Create .env file make env # Update the values in .env file by adding in your Client ID and Sandbox Access key. # API_CLIENT_ID= # API_SECRET= # Also, in .env uncomment the line with API_PRODUCT_TYPE that you want to use # API_PRODUCT_TYPE=employment # API_PRODUCT_TYPE=income # API_PRODUCT_TYPE=deposit_switch # API_PRODUCT_TYPE=pll # API_PRODUCT_TYPE=admin # Run the make script for your coding language make python_local ``` -------------------------------- ### Clone and Configure Truv Quickstart (Python Docker) Source: https://docs.truv.com/docs This snippet shows how to clone the Truv Quickstart repository, navigate to the Python directory, copy the example environment file, and configure it with your Client ID, Access Key, and desired Product Type for Docker execution. ```bash # Clone the Quickstart repository git clone https://github.com/citadelid/quickstart.git # Open Quickstart in your coding language cd quickstart/python # Copy the .env.example file to a new file in the same directory and name it .env. cp .env.example .env # Update the values adding in the your Client ID and Sandbox Access key. #API_CLIENT_ID= #API_SECRET= # Uncomment the line with API_PRODUCT_TYPE that you want to use #API_PRODUCT_TYPE=employment #Run the make script for your coding language make python_docker ``` -------------------------------- ### GET /links/{link_id}/income/report Source: https://docs.truv.com/docs/quickstart-guide Retrieves basic information about the consumer's income and employment using the provided link_id. ```APIDOC ## GET /links/{link_id}/income/report ### Description Retrieves basic information about the consumer's income and employment. ### Method GET ### Endpoint /links/{link_id}/income/report ### Parameters #### Path Parameters - **link_id** (string) - Required - The unique identifier for the link. ### Request Example (No request body for this GET request) ### Response #### Success Response (200) - **income_report** (object) - An object containing the consumer's income and employment details. #### Response Example ```json { "income_report": { "employer": "Example Corp", "job_title": "Software Engineer", "years_employed": 2, "income": 120000 } } ``` ``` -------------------------------- ### GET /links/{link_id}/income/report Source: https://docs.truv.com/docs/quickstart-1 Retrieves basic information about the consumer's income and employment using the provided link_id. ```APIDOC ## GET /links/{link_id}/income/report ### Description This endpoint retrieves basic information about the consumer's income and employment. It requires a `link_id` as a path parameter. ### Method GET ### Endpoint /links/{link_id}/income/report ### Parameters #### Path Parameters - **link_id** (string) - Required - The unique identifier for the link. ### Request Example (No request body is typically sent for a GET request of this nature) ### Response #### Success Response (200) - **income_data** (object) - Contains detailed information about the consumer's income and employment. #### Response Example { "income_data": { "employment_status": "Employed", "employer_name": "Example Corp", "income_amount": 50000, "pay_frequency": "Monthly" } } ``` -------------------------------- ### Truv Income and Employment API Example Response (JSON) Source: https://docs.truv.com/docs/quickstart-1 This JSON object represents a sample payload received from the Truv Income and Employment API. It includes details about the employment status, job, company, income, and associated statements, as well as profile and bank account information. ```json { "id": "24d7e80942ce4ad58a93f70ce4115f5c", "status": "new", "completed_at": "2021-04-06 11:30:00+00:00", "access_token": "48427a36d43c4d5aa6324bc06c692456", "tracking_info": "user123456", "refresh_status": "new", "employments": [ { "id": "24d7e80942ce4ad58a93f70ce4115f5c", "job_title": "PR associate", "job_type": "F", "start_date": "2018-01-01", "end_date": "2019-08-24", "external_last_updated": "2019-08-24", "original_hire_date": "2017-06-21", "is_active": false, "dates_from_statements": false, "derived_fields": [ "is_active" ], "missing_data_fields": [ "w2s" ], "profile": { "first_name": "John", "last_name": "Doe", "middle_initials": "K", "ssn": "123456789", "email": "john.doe@example.com", "date_of_birth": "1992-03-03", "home_address": { "street": "1 Morgan Ave", "city": "Los Angeles", "state": "CA", "zip": "90210" } }, "company": { "name": "Facebook Demo", "address": { "street": "1 Hacker Way", "city": "Menlo Park", "state": "CA", "zip": "94025" }, "phone": "6503087300" }, "income": "70000.00", "income_unit": "YEARLY", "pay_frequency": "M", "manager_name": "Jenny McDouglas", "statements": [ { "id": "24d7e80942ce4ad58a93f70ce4115f5c", "pay_date": "2018-05-15", "net_pay": "11500.32", "net_pay_ytd": "31980.64", "gross_pay": "13900.11", "gross_pay_ytd": "49200.00", "bonus": "100.00", "commission": "12000.00", "hours": "40.00", "basis_of_pay": "S", "period_start": "2018-05-01", "period_end": "2018-05-15", "regular": "1695.11", "regular_ytd": "23000.00", "bonus_ytd": "1000.00", "commission_ytd": "24000.00", "overtime": "45.00", "overtime_ytd": "500.00", "other_pay": "60.00", "other_pay_ytd": "700.00", "earnings": [ {} ], "earnings_ytd": [ {} ], "deductions": [ {} ], "deductions_ytd": [ {} ], "md5sum": "03639d6a6624f69a54a88ea90bd25e9d", "file": "https://citadelid-resources.s3-us-west-2.amazonaws.com/paystub_sample.pdf" } ], "annual_income_summary": [ { "id": "24d7e80942ce4ad58a93f70ce4115f5c", "year": 2018, "regular": "23000.00", "bonus": "1000.00", "commission": "24000.00", "overtime": "500.00", "other_pay": "700.00", "net_pay": "31980.64", "gross_pay": "49200.00" } ], "bank_accounts": [ { "account_number": "1234567890", "routing_number": "123456789", "account_name": "My Bank", "account_type": "C", "deposit_type": "A", "deposit_value": "200.00", "bank_name": "TD Bank" } ], "annual_salary": "70000.00", "hourly_salary": "36.40", "w2s": [ { "file": "https://citadelid-resources.s3-us-west-2.amazonaws.com/W2_sample.pdf", "md5sum": "f65e30c39124ad707ac4b3aeaee923a7", "year": 2020 } ] } ], "provider": "adp" } ``` -------------------------------- ### GET /websites/truv Source: https://docs.truv.com/reference/employment Retrieves the example response for the Truv website, showcasing employment and income details. ```APIDOC ## GET /websites/truv ### Description This endpoint returns an example JSON response detailing employment information, including income, job title, company details, and dates. ### Method GET ### Endpoint /websites/truv ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **id** (string) - Unique identifier for the employment record. - **income** (string) - The reported income amount. - **income_unit** (string) - The unit of the income (e.g., 'YEARLY'). - **pay_rate** (string) - The pay rate. - **pay_frequency** (string) - The frequency of pay (e.g., 'M' for monthly). - **is_active** (boolean) - Indicates if the employment is currently active. - **job_title** (string) - The title of the job. - **job_type** (string) - The type of job (e.g., 'F' for full-time). - **start_date** (string) - The start date of employment. - **original_hire_date** (string) - The original hire date. - **end_date** (string) - The end date of employment. - **external_last_updated** (string) - The last updated date from an external source. - **derived_fields** (array) - List of fields that are derived. - **missing_data_fields** (array) - List of fields with missing data. - **manager_name** (string) - The name of the manager. - **company** (object) - Details about the company. - **name** (string) - The name of the company. - **address** (object) - The company's address. - **street** (string) - Street address. - **city** (string) - City. - **state** (string) - State. - **zip** (string) - Zip code. - **country** (string) - Country. - **phone** (string) - Company phone number. - **ein** (string) - Company EIN. #### Response Example ```json { "id": "24d7e80942ce4ad58a93f70ce4115f5c", "income": "70000.00", "income_unit": "YEARLY", "pay_rate": "6500.00", "pay_frequency": "M", "is_active": false, "job_title": "PR associate", "job_type": "F", "start_date": "2018-01-01", "original_hire_date": "2017-06-21", "end_date": "2022-12-11", "external_last_updated": "2022-12-11", "derived_fields": [ "is_active" ], "missing_data_fields": [ "w2s" ], "manager_name": "Jenny McDouglas", "company": { "name": "Facebook Demo", "address": { "street": "1 Morgan Ave", "city": "Los Angeles", "state": "CA", "zip": "90210", "country": "US" }, "phone": "6503087300", "ein": "12-345678" } } ``` ``` -------------------------------- ### Configure Truv API Constants for Android Source: https://docs.truv.com/docs/quickstart-1 This code snippet shows how to set up constants for Truv API integration in an Android application. It involves cloning the Android Quickstart repository, creating a local.properties file, and defining variables for the client ID, secret, API URL, and product type. These configurations are necessary for authenticating and making requests to the Truv API. The code requires Android Studio for execution. ```kotlin /* Clone the Quickstart repository: git clone https://github.com/truvhq/quickstart-android.git Open Quickstart: cd quickstart-android Create constants file: touch local.properties */ truvClientId="" truvSecret="" truvApiUrl="https://prod.truv.com/v1/" truvProductType="" /* Open the project in Android Studio and run the app */ ``` -------------------------------- ### Retrieve Income Report by Link ID (Go) Source: https://docs.truv.com/docs/quickstart-guide Retrieves the income verification data for a consumer using their link_id. This function logs the request details, constructs an HTTP GET request, and executes it using an HTTP client. It handles potential errors during request creation and execution, returning the response body as a string or an error. ```go func getIncomeInfoByLinkId(link_id string) (string, error) { log.Println("TRUV: Requesting income verification data from https://prod.truv.com/v1/links/:link_id/income/report") log.Printf("TRUV: Link ID - %s\n", link_id) request, err := getRequest(fmt.Sprintf("links/%s/income/report", link_id), "GET", nil) if err != nil { return "", err } client := &http.Client{} res, err := client.Do(request) if err != nil { return "", err } defer res.Body.Close() data, _ := ioutil.ReadAll(res.Body) return string(data), nil } ``` -------------------------------- ### Retrieve Income Report by Link ID (Python) Source: https://docs.truv.com/docs/quickstart-guide Fetches the income report for a consumer using their link_id. This function makes a GET request to the /links/{link_id}/income/report endpoint. It requires the 'link_id' as a string input and returns a dictionary containing the income data. ```python def get_income_info_by_link_id(self, link_id: str) -> dict: logging.info( "TRUV: Requesting income report data from https://prod.truv.com/v1/links/:link_id/income/report" ) logging.info("TRUV: Link ID - %s", link_id) return self.get(f"links/{link_id}/income/report") ``` -------------------------------- ### Get Income Report by Link ID (Python, JavaScript, Go) Source: https://docs.truv.com/docs/quickstart-1 This function retrieves a consumer's income report using their `link_id`. It logs the request details and then calls the appropriate HTTP GET endpoint. Dependencies include standard libraries for HTTP requests and logging. The input is a `link_id` string, and the output is a dictionary (Python), JSON response (JavaScript), or a string representing the response body (Go). ```python def get_income_info_by_link_id(self, link_id: str) -> dict: logging.info( "TRUV: Requesting income report data from https://prod.truv.com/v1/links/:link_id/income/report" ) logging.info("TRUV: Link ID - %s", link_id) return self.get(f"links/{link_id}/income/report") ``` ```javascript const getIncomeInfoByLinkId = async (link_id) => { console.log( 'TRUV: Requesting income verification data from https://prod.truv.com/v1/links/:link_id/income/report', ); console.log(`TRUV: Link ID - ${link_id}`); return await sendRequest('links/${link_id}/income/report', { method: "GET" }); }; ``` ```go func getIncomeInfoByLinkId(link_id string) (string, error) { log.Println("TRUV: Requesting income verification data from https://prod.truv.com/v1/links/:link_id/income/report") log.Printf("TRUV: Link ID - %s\n", link_id) request, err := getRequest(fmt.Sprintf("links/%s/income/report", link_id), "GET", nil) if err != nil { return "", err } client := &http.Client{} res, err := client.Do(request) if err != nil { return "", err } defer res.Body.Close() data, _ := ioutil.ReadAll(res.Body) return string(data), nil } ``` -------------------------------- ### Configure Truv API Constants for iOS Source: https://docs.truv.com/docs/quickstart-1 This Swift code snippet demonstrates how to configure constants for the Truv API integration on iOS. It involves cloning the iOS Quickstart repository, creating a Constants.swift file, and defining variables for client ID, secret, API URL, and product type. These values are essential for authenticating and interacting with the Truv API. The code requires Xcode for running the application. ```swift /* Clone the Quickstart repository: git clone https://github.com/truvhq/quickstart-ios.git Open Quickstart: cd quickstart-ios Create constants file: touch truv-quickstart/Constants.swift */ import Foundation var TruvClientID = "" var TruvClientSecret = "" var TruvAPIUrl = "https://prod.truv.com/v1/" var TruvProductType = "" /* Open the project in XCode and run the app */ ``` -------------------------------- ### Webhook Example Source: https://docs.truv.com/docs/implementing-bank-aggregation-solution An example of a webhook payload. Webhooks notify your server about status changes for tasks and links, allowing for real-time monitoring and updates. ```APIDOC ## Webhook Notification Example ### Description This is an example of a webhook payload that your server might receive. Webhooks are used to monitor status changes of tasks and link connections, identified by `link_id` or `task_id`. ### Response Example ```json { "webhook_id": "609a82aab21e4d9ba2569f35e9e8f26a", "event_type": "task-status-updated", "updated_at": "2021-04-26T13:02:20.369267+00:00", "task_id": "67f2924530564282bbaf6d27655e94a4", "link_id": "64f8e374949c4b769706028022626bf1", "product": "transactions", "tracking_info": "27266f35-bb54-44c3-8905-070641a0c0aa", "status": "login" } ``` ``` -------------------------------- ### Go: Make authenticated API request Source: https://docs.truv.com/docs/quickstart-guide This Go code snippet demonstrates how to construct and perform an authenticated HTTP POST request to a Truv API endpoint. It handles request creation, client execution, response reading, and error checking, including deferring the closing of the response body. ```Go func getRequest(path string, method string, body []byte) (*http.Request, error) { url := fmt.Sprintf("https://prod.truv.com/v1/%s", path) request, err := http.NewRequest(method, url, bytes.NewBuffer(body)) if err != nil { return nil, err } request.Header.Set("Content-Type", "application/json") request.Header.Set("x-api-key", os.Getenv("TRUV_API_KEY")) return request, nil } func main() { userId := "example_user_id" account := Account{} account.DepositType = "amount" account.DepositValue = "1" bridgeTokenRequest := BridgeTokenRequest{} bridgeTokenRequest.Account = &account bridgeJson, _ := json.Marshal(bridgeTokenRequest) request, err := getRequest(fmt.Sprintf("users/%s/tokens/", userId), "POST", bridgeJson) if err != nil { return "", err } client := &http.Client{} response, err := client.Do(request) if err != nil { return "", err } defer response.Body.Close() data, _ := ioutil.ReadAll(response.Body) return (string(data)), nil } ``` -------------------------------- ### Create Truv User and Bridge Token Source: https://docs.truv.com/docs/quickstart-1 This snippet demonstrates how to create a new user with Truv and then generate a bridge token for authentication. It handles different product types and includes logging for requests. The bridge token is temporary and expires after 6 hours. ```python import logging import uuid # Assuming 'self' is an instance of a class with a 'post' method # and necessary configurations like API endpoint and product_type are set. class TruvAPI: def __init__(self, product_type): self.product_type = product_type # Assume self.post method is defined elsewhere to handle HTTP POST requests # Example: def post(self, endpoint, json): # pass def create_user(self, **kwargs) -> dict: logging.info("TRUV: Requesting new user from https://prod.truv.com/v1/users/") payload = { "external_user_id": f"qs-{uuid.uuid4().hex}", "first_name": "John", "last_name": "Johnson", "email": "j.johnson@example.com", **kwargs, } return self.post("users/", json=payload) def create_user_bridge_token(self, user_id: str) -> dict: logging.info( "TRUV: Requesting user bridge token from https://prod.truv.com/v1/users/{user_id}/tokens" ) logging.info("TRUV: User ID - %s", user_id) payload = { "product_type": self.product_type, "tracking_info": "1338-0111-A", } if self.product_type in ["deposit_switch", "pll"]: payload["account"] = { "account_number": "16002600", "account_type": "checking", "routing_number": "12345678", "bank_name": "Example Bank", } if self.product_type == "pll": payload["account"].update({ "deposit_type": "amount", "deposit_value": "100", }) return self.post(f"users/{user_id}/tokens/", json=payload) ``` -------------------------------- ### Initialize Truv Bridge with JavaScript Source: https://docs.truv.com/docs/quickstart-1 Initializes the Truv Bridge module in a web client, passing a bridge token and defining callback functions for load, success, event, and close events. It requires the `TruvBridge` object to be available in the global scope. ```javascript const bridge = TruvBridge.init({ bridgeToken: bridgeToken.bridge_token, onLoad: function() { console.log('Bridge loaded'); }, onSuccess: function(public_token, meta) { console.log('Success:', public_token); }, onEvent: function(event_type, payload) { console.log('Event:', event_type); }, onClose: function() { console.log('Bridge closed'); } }); window.bridge = bridge; ``` -------------------------------- ### Create Truv User and Bridge Token (JavaScript) Source: https://docs.truv.com/docs/quickstart-1 This asynchronous JavaScript function creates a new user with Truv and then generates a bridge token. It uses the Fetch API for HTTP requests and includes error handling. The `PRODUCT_TYPE` constant and `crypto.randomUUID()` are used for user identification and token generation. ```javascript const BASE_URL = 'https://prod.truv.com/v1'; const PRODUCT_TYPE = 'deposit_switch'; async function createUser(options = {}) { console.log("TRUV: Requesting new user from https://prod.truv.com/v1/users/"); const payload = { external_user_id: `qs-${crypto.randomUUID()}`, first_name: "John", last_name: "Johnson", email: "j.johnson@example.com", ...options }; try { const response = await fetch(`${BASE_URL}/users/`, { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify(payload) }); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } return response.json(); } catch (error) { console.error('Error creating user:', error); throw error; } } async function createUserBridgeToken(userId) { if (!userId) { throw new Error('userId is required'); } console.log(`TRUV: Requesting user bridge token from ${BASE_URL}/users/${userId}/tokens`); console.log("TRUV: User ID - ", userId); const payload = { product_type: PRODUCT_TYPE, tracking_info: "1338-0111-A", }; if (PRODUCT_TYPE === "deposit_switch" || PRODUCT_TYPE === "pll") { payload.account = { account_number: "16002600", account_type: "checking", routing_number: "12345678", bank_name: "Example Bank", }; if (PRODUCT_TYPE === "pll") { payload.account = { ...payload.account, deposit_type: "amount", deposit_value: "100", }; } } try { const response = await fetch(`${BASE_URL}/users/${userId}/tokens/`, { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify(payload) }); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } return response.json(); } catch (error) { console.error('Error creating bridge token:', error); throw error; } } ``` -------------------------------- ### Create User and Bridge Token - Python Source: https://docs.truv.com/docs Python functions to create a new user with Truv and subsequently request a user bridge token. The bridge token is temporary and used for authentication. It handles different product types for the bridge token request. ```Python import logging import uuid # Assuming 'self' has a 'post' method for making API calls # and the class has 'product_type' attribute def create_user(self, **kwargs) -> dict: logging.info("TRUV: Requesting new user from https://prod.truv.com/v1/users/") payload = { "external_user_id": f"qs-{uuid.uuid4().hex}", "first_name": "John", "last_name": "Johnson", "email": "j.johnson@example.com", **kwargs, } return self.post("users/", json=payload) def create_user_bridge_token(self, user_id: str) -> dict: logging.info( "TRUV: Requesting user bridge token from https://prod.truv.com/v1/users/{user_id}/tokens" ) logging.info("TRUV: User ID - %s", user_id) payload = { "product_type": self.product_type, "tracking_info": "1338-0111-A", } if self.product_type in ["deposit_switch", "pll"]: payload["account"] = { "account_number": "16002600", "account_type": "checking", "routing_number": "12345678", "bank_name": "Example Bank", } if self.product_type == "pll": payload["account"].update( { "deposit_type": "amount", "deposit_value": "100", } ) return self.post(f"users/{user_id}/tokens/", json=payload) ``` -------------------------------- ### Exchange Public Token for Access Token with JavaScript Source: https://docs.truv.com/docs/quickstart-1 Handles the server-side exchange of a Truv `public_token` for an `access_token` using JavaScript. It logs the public token, constructs the request body, and sends it to the Truv API endpoint. The response containing the `access_token` is then returned. ```javascript const getAccessToken = async (public_token) => { console.log('TRUV: Exchanging a public_token for an access_token from https://prod.truv.com/v1/link-access-tokens'); console.log(`TRUV: Public Token - ${public_token}`); const body = JSON.stringify({ public_token: public_token, }); const responseBody = await sendRequest('link-access-tokens/', { body }); return responseBody; }; ``` -------------------------------- ### Create Truv User and Bridge Token (Go) Source: https://docs.truv.com/docs/quickstart-1 This Go code snippet shows how to create a Truv user and then request a bridge token. It uses the standard Go `net/http` package and `encoding/json` for JSON handling. Environment variables are used to configure the product type, and basic error handling is included. ```go import ( "encoding/json" "fmt" "log" "net/http" "os" "time" ) // Assuming UserRequest, UserResponse, BridgeTokenRequest, AccountRequest structs are defined elsewhere // Also assuming getRequest function is defined to create an http.Request // Placeholder for required structs and functions type UserRequest struct { ExternalUserId string `json:"external_user_id"` FirstName string `json:"first_name"` LastName string `json:"last_name"` Email string `json:"email"` } type UserResponse struct { UserId string `json:"user_id"` // Other fields as per API response } type BridgeTokenRequest struct { ProductType string `json:"product_type"` TrackingInfo string `json:"tracking_info"` Account *AccountRequest `json:"account,omitempty"` } type AccountRequest struct { AccountNumber string `json:"account_number"` AccountType string `json:"account_type"` RoutingNumber string `json:"routing_number"` BankName string `json:"bank_name"` DepositType string `json:"deposit_type,omitempty"` DepositValue string `json:"deposit_value,omitempty"` } func getRequest(endpoint string, method string, payload []byte) (*http.Request, error) { // Placeholder for actual request creation logic // This function should construct and return an http.Request // Example: baseURL := "https://prod.truv.com/v1" req, err := http.NewRequest(method, fmt.Sprintf("%s/%s", baseURL, endpoint), bytes.NewBuffer(payload)) if err != nil { return nil, err } req.Header.Set("Content-Type", "application/json") // Add authentication headers if needed return req, nil } func createUser() (string, error) { log.Println("TRUV: Requesting new user from https://prod.truv.com/v1/users/") uniqueNumber := time.Now().UnixNano() / (1 << 22) // Example of generating a unique ID userRequest := UserRequest{ ExternalUserId: fmt.Sprintf("qs-%d", uniqueNumber), FirstName: "John", LastName: "Johnson", Email: "j.johnson@example.com", } userJson, _ := json.Marshal(userRequest) request, err := getRequest("users/", "POST", userJson) if err != nil { return "", err } client := &http.Client{} res, err := client.Do(request) if err != nil { return "", err } defer res.Body.Close() user := UserResponse{} err = json.NewDecoder(res.Body).Decode(&user) return user.UserId, nil } func createUserBridgeToken(userId string) (string, error) { log.Println("TRUV: Requesting user bridge token from https://prod.truv.com/v1/users/{user_id}/tokens") log.Printf("TRUV: User ID - %s\n", userId) productType := os.Getenv("API_PRODUCT_TYPE") bridgeTokenRequest := BridgeTokenRequest{ ProductType: productType, TrackingInfo: "1338-0111-A", } if productType == "pll" || productType == "deposit_switch" { account := AccountRequest{ AccountNumber: "1600200", AccountType: "checking", RoutingNumber: "123456789", BankName: "TD Bank", } if productType == "pll" { account.DepositType = "amount" account.DepositValue = "100" } bridgeTokenRequest.Account = &account } bridgeTokenJson, _ := json.Marshal(bridgeTokenRequest) request, err := getRequest(fmt.Sprintf("users/%s/tokens/", userId), "POST", bridgeTokenJson) if err != nil { return "", err } client := &http.Client{} res, err := client.Do(request) if err != nil { return "", err } defer res.Body.Close() // Assuming a response struct for bridge token is defined type BridgeTokenResponse struct { BridgeToken string `json:"bridge_token"` // Other fields } bridgeTokenResponse := BridgeTokenResponse{} err = json.NewDecoder(res.Body).Decode(&bridgeTokenResponse) if err != nil { return "", err } return bridgeTokenResponse.BridgeToken, nil } ``` -------------------------------- ### GET /links/{link_id}/income/report Source: https://docs.truv.com/docs Retrieves basic information about a consumer's income and employment using a provided link_id. ```APIDOC ## GET /links/{link_id}/income/report ### Description This endpoint retrieves basic information about the consumer's income and employment. ### Method GET ### Endpoint /links/{link_id}/income/report ### Parameters #### Path Parameters - **link_id** (string) - Required - The unique identifier for the link. ### Request Example ```json { "example": "GET /links/your_link_id/income/report" } ``` ### Response #### Success Response (200) - **income_report** (object) - Contains details about the consumer's income. - **employment_report** (object) - Contains details about the consumer's employment. #### Response Example ```json { "income_report": { "total_income": 50000, "pay_frequency": "monthly" }, "employment_report": { "employer_name": "Tech Corp", "job_title": "Software Engineer" } } ``` ``` -------------------------------- ### Create Truv User and Bridge Token (Go) Source: https://docs.truv.com/docs/quickstart-guide This Go code includes functions to create a Truv user and request a bridge token. `createUser` generates a unique external user ID and makes a POST request to the users endpoint. `createUserBridgeToken` constructs a request for a bridge token, incorporating environment variables for product type and conditional account details. ```go import ( "encoding/json" "fmt" "log" "net/http" "os" "time" ) // Assuming UserRequest, UserResponse, BridgeTokenRequest, AccountRequest structs are defined elsewhere // and helper functions like getRequest, post are available. func createUser() (string, error) { log.Println("TRUV: Requesting new user from https://prod.truv.com/v1/users/") uniqueNumber := time.Now().UnixNano() / (1 << 22) // Example of generating a unique ID part userRequest := UserRequest{ ExternalUserId: fmt.Sprintf("qs-%d", uniqueNumber), FirstName: "John", LastName: "Johnson", Email: "j.johnson@example.com", } userJson, _ := json.Marshal(userRequest) request, err := getRequest("users/", "POST", userJson) // Assuming getRequest constructs the http.Request if err != nil { return "", err } client := &http.Client{} res, err := client.Do(request) if err != nil { return "", err } defer res.Body.Close() user := UserResponse{} err = json.NewDecoder(res.Body).Decode(&user) if err != nil { return "", err } return user.UserId, nil } func createUserBridgeToken(userId string) (string, error) { log.Println("TRUV: Requesting user bridge token from https://prod.truv.com/v1/users/{user_id}/tokens") log.Printf("TRUV: User ID - %s\n", userId) productType := os.Getenv("API_PRODUCT_TYPE") // Example of getting product type from environment bridgeTokenRequest := BridgeTokenRequest{ ProductType: productType, TrackingInfo: "1338-0111-A", } if productType == "pll" || productType == "deposit_switch" { account := AccountRequest{ AccountNumber: "1600200", AccountType: "checking", RoutingNumber: "123456789", BankName: "TD Bank", } if productType == "pll" { // Logic for PLL specific account details would go here // Example: account.DepositType = "amount" // Example: account.DepositValue = "100" } bridgeTokenRequest.Account = account } // Assuming a post function or direct http client usage to send the request // Example: // payload, _ := json.Marshal(bridgeTokenRequest) // response, err := post(fmt.Sprintf("users/%s/tokens/", userId), payload) // if err != nil { // return "", err // } // return response.BridgeToken, nil // Assuming response struct has BridgeToken field return "", nil // Placeholder return } ``` -------------------------------- ### Create Truv User and Bridge Token (Python) Source: https://docs.truv.com/docs/quickstart-guide This Python code defines two functions to interact with the Truv API. `create_user` creates a new user with basic details, and `create_user_bridge_token` requests a temporary bridge token for an existing user. It handles different product types and includes conditional logic for account details when required. ```python import logging from uuid import uuid4 # Assume 'self' is an instance of a Truv API client class # with a 'post' method defined. def create_user(self, **kwargs) -> dict: logging.info("TRUV: Requesting new user from https://prod.truv.com/v1/users/") payload = { "external_user_id": f"qs-{uuid4().hex}", "first_name": "John", "last_name": "Johnson", "email": "j.johnson@example.com", **kwargs, } return self.post("users/", json=payload) def create_user_bridge_token(self, user_id: str) -> dict: logging.info( "TRUV: Requesting user bridge token from https://prod.truv.com/v1/users/{user_id}/tokens" ) logging.info("TRUV: User ID - %s", user_id) payload = { "product_type": self.product_type, "tracking_info": "1338-0111-A", } if self.product_type in ["deposit_switch", "pll"]: payload["account"] = { "account_number": "16002600", "account_type": "checking", "routing_number": "12345678", "bank_name": "Example Bank", } if self.product_type == "pll": payload["account"].update( { "deposit_type": "amount", "deposit_value": "100", } ) return self.post(f"users/{user_id}/tokens/", json=payload) ``` -------------------------------- ### POST /orders/ Source: https://docs.truv.com/docs/implementation-with-a-custom-loan-origination-system-guide Creates a new order for verification of income and employment. You can specify products, borrower details, and optional loan or employer information. ```APIDOC ## POST /orders/ ### Description Creates a new order for verification of income and employment. You can specify products, borrower details, and optional loan or employer information. ### Method POST ### Endpoint /orders/ ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **products** (array of strings) - Required - The product(s) desired. E.g., `["income"]`. - **first_name** (string) - Required - The first name of the borrower. - **last_name** (string) - Required - The last name of the borrower. - **email** (string) - Optional - The email address for notifications. - **phone** (string) - Optional - The mobile phone number for notifications. - **loan** (object) - Optional - Loan identification details. - **loan_number** (string) - Optional - The loan number. - **originator_name** (string) - Optional - The first and last name of the loan originator. - **originator_email** (string) - Optional - The email of the loan originator. - **loan_processor_name** (string) - Optional - The first and last name of the loan processor. - **loan_processor_email** (string) - Optional - The email of the loan processor. - **ssn** (string) - Optional - Borrower's social security number (4 or 9 digits). - **manager** (object) - Optional - Information about the Truv Order creator. - **email** (string) - Required - The email of the Order creator. - **name** (string) - Required - The first and last name of the Order creator. - **employers** (array of objects) - Optional - Employment information for the borrower (up to 5). - **start_date** (string) - Optional - The start date of employment (YYYY-MM-DD). - **company_name** (string) - Optional - The name of the employer. - **data_sources** (array of strings) - Optional - Data sources to use. E.g., `["payroll"]`, `["payroll", "docs"]`. - **template_id** (string) - Optional - The ID of a custom template to use. ### Request Example ```json { "products": ["income"], "first_name": "John", "last_name": "Doe", "email": "john.doe@example.com", "loan": { "loan_number": "LN12345", "originator_name": "Jane Smith", "loan_processor_email": "processor@example.com" }, "ssn": "xxxx", "manager": { "email": "manager@truv.com", "name": "Manager Name" }, "employers": [ { "start_date": "2020-01-15", "company_name": "Example Corp" } ], "data_sources": ["payroll", "docs"], "template_id": "tpl_abc123" } ``` ### Response #### Success Response (200) - **order_id** (string) - The unique identifier for the created order. - **share_url** (string) - A URL to share with the borrower for verification. - **status** (string) - The current status of the order. #### Response Example ```json { "order_id": "ord_12345", "share_url": "https://verification.truv.com/verify/ord_12345", "status": "pending" } ``` ```