Company Users Endpoint
Validate user lists against your internal employee systems.
Overview
This document outlines the process for using the Snapdocs GET call for company users. This endpoint allows you to validate current users and address general user-matching needs against core Employee systems, serving as an effective alternative to a dedicated user-synchronization integration.
Details
GET /api/v1/company_users available at GET Company Users will return the full list of users and their current active status.
User email address is the expected user object connection between Snapdocs and lender User systems, in that email is the username for sign on in the Snapdocs platform.
Snapdocs assumes SSO, SCIM, or manual intervention on the Users list in the Admin page of the UI is the resulting action when there are users that do not meet your expectations.
Please note that there is a Snapdocs user that is required to exist on the account as account owner, and will be in the returned user list.
Example Script
This script is meant as a starting point for your exercise, as it does not know what user-synchronization work would include. We hit our cs-demo0 non-production API endpoint, return a list of users, and print to the command line. The script starts with a Bearer token while a real solution would make the auth call at the Oauth Guide.
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text.Json;
using System.Threading.Tasks;
namespace GetUsersScript
{ public class CompanyUser // Model for the user data from Snapdocs API
{
public bool active { get; set; }
public string email { get; set; } = string.Empty;
public string first_name { get; set; } = string.Empty;
public string last_name { get; set; } = string.Empty;
public string role { get; set; } = string.Empty;
}
public class GetUsersResponse // Model for the API response
{
public List<CompanyUser> company_users { get; set; } = new List<CompanyUser>();
}
class Program
{
private static readonly HttpClient httpClient = new HttpClient();
private const string SNAPDOCS_API_USERS_URL = "https://api.cs-demo0.snpd.io/api/v1/company_users"; // Update with actual base URL
private const string BEARER_TOKEN = "<your_bearer_token_here>"; // Use full with Auth call https://snapdocs-closings.readme.io/reference/generatetoken-1
static async Task Main(string[] args)
{
Console.WriteLine("Starting Snapdocs Get Users Script...");
Console.WriteLine();
try
{
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", BEARER_TOKEN);
httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
var users = await GetUsersFromSnapdocs();
ProcessUsers(users);
}
catch (Exception ex)
{
Console.WriteLine($"Error occurred: {ex.Message}");
Console.WriteLine($"Stack trace: {ex.StackTrace}");
}
finally
{
httpClient.Dispose();
}
Console.WriteLine();
Console.WriteLine("Script completed. Press any key to exit...");
Console.ReadKey();
}
private static async Task<List<CompanyUser>> GetUsersFromSnapdocs()
{
Console.WriteLine("Calling Snapdocs Get Users API...");
string apiUrl = $"{SNAPDOCS_API_USERS_URL}";
var response = await httpClient.GetAsync(apiUrl);
if (response.IsSuccessStatusCode)
{
var jsonContent = await response.Content.ReadAsStringAsync();
Console.WriteLine($"API Successful! Response received: {jsonContent.Length} characters");
Console.WriteLine();
var apiResponse = JsonSerializer.Deserialize<GetUsersResponse>(jsonContent, new JsonSerializerOptions{ PropertyNameCaseInsensitive = true});
return apiResponse?.company_users ?? new List<CompanyUser>();
}
else
{
throw new HttpRequestException($"API call failed with status code: {response.StatusCode}. Reason: {response.ReasonPhrase}");
}
}
private static void ProcessUsers(List<CompanyUser> users)
{
Console.WriteLine($"Processing {users.Count} users from Snapdocs...");
Console.WriteLine(new string('-', 60));
for (int i = 0; i < users.Count; i++)
{
//In your implementation, you would run a comparison against the IDP with this data.
var user = users[i];
Console.WriteLine($"User {i + 1}: {user.first_name} {user.last_name} : {user.email} : {user.role} : active={user.active}");
}
}
}
}
Updated about 1 month ago