Company Users Guide
Overview
The User Management API allows you to:
- Retrieve current user profile information
- List companies associated with your account
- View detailed company information and permissions
Get Current User Profile
Retrieve detailed information about the currently authenticated user, including their associated companies.
Endpoint
GET /user/me
Example Request
- cURL
- JavaScript
- TypeScript
- PHP
curl -X GET "https://deepsy.fr/api/v1/user/me" \
-H "Authorization: Bearer deepsy-dev-your-api-key-here"
const response = await fetch('https://deepsy.fr/api/v1/user/me', {
method: 'GET',
headers: {
'Authorization': 'Bearer deepsy-dev-your-api-key-here'
}
});
const userProfile = await response.json();
console.log(userProfile);
interface UserProfile {
first_name: string;
last_name: string;
display_name: string;
gender?: string;
age?: number;
email: string;
phone_number?: string;
country?: string;
city?: string;
profile_picture?: string;
biography?: string;
welcome_message?: string;
email_verified_at?: string;
companies: Array<{
company_id: string;
permissions: number;
company: {
name: string;
profile_picture?: string;
};
}>;
}
const response = await fetch('https://deepsy.fr/api/v1/user/me', {
method: 'GET',
headers: {
'Authorization': 'Bearer deepsy-dev-your-api-key-here'
}
});
const userProfile: UserProfile = await response.json();
console.log(userProfile);
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => 'https://deepsy.fr/api/v1/user/me',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer deepsy-dev-your-api-key-here'
],
]);
$response = curl_exec($curl);
$userProfile = json_decode($response, true);
curl_close($curl);
print_r($userProfile);
?>
Response
{
"first_name": "John",
"last_name": "Doe",
"display_name": "John Doe",
"gender": "male",
"age": 30,
"email": "john.doe@example.com",
"phone_number": "+33123456789",
"country": "France",
"city": "Paris",
"profile_picture": "https://example.com/avatar.jpg",
"biography": "Psychology professional with 10 years of experience",
"welcome_message": "2023-01-15T10:30:00Z",
"email_verified_at": "2023-01-15T10:30:00Z",
"companies": [
{
"company_id": "c193a06f-1c25-4e65-84a7-95faaae7ae7b",
"permissions": 6,
"company": {
"name": "Acme Corporation",
"profile_picture": "https://example.com/company-logo.jpg"
}
}
]
}
Response Fields
Field | Type | Description |
---|---|---|
first_name | string | User's first name |
last_name | string | User's last name |
display_name | string | User's display name |
gender | string | User's gender |
age | integer | User's age (nullable) |
email | string | User's email address |
phone_number | string | User's phone number (nullable) |
country | string | User's country (nullable) |
city | string | User's city (nullable) |
profile_picture | string | URL to user's profile picture (nullable) |
biography | string | User's biography (nullable) |
welcome_message | string | Timestamp when welcome message was shown (nullable) |
email_verified_at | string | Email verification timestamp (nullable) |
companies | array | List of companies (limited to 10) |
Company Object
Each company in the companies
array contains:
Field | Type | Description |
---|---|---|
company_id | string (UUID) | Company identifier |
permissions | integer | Permission bitfield for this company |
company.name | string | Company name |
company.profile_picture | string | Company profile picture URL (nullable) |
List User Companies
Retrieve a comprehensive list of all companies the authenticated user is associated with, including detailed company information and permissions.
Endpoint
GET /user/companies
Example Request
- cURL
- JavaScript
- TypeScript
- PHP
curl -X GET "https://deepsy.fr/api/v1/user/companies" \
-H "Authorization: Bearer deepsy-dev-your-api-key-here"
const response = await fetch('https://deepsy.fr/api/v1/user/companies', {
method: 'GET',
headers: {
'Authorization': 'Bearer deepsy-dev-your-api-key-here'
}
});
const companies = await response.json();
console.log(companies);
interface CompanyMembership {
company_id: string;
permissions: string[];
created_at: string;
updated_at: string;
invitation_code?: string;
company: {
name: string;
profile_picture?: string;
email?: string;
website?: string;
industry?: string;
size?: string;
country?: string;
city?: string;
};
}
interface CompanyListResponse {
items: CompanyMembership[];
count: number;
}
const response = await fetch('https://deepsy.fr/api/v1/user/companies', {
method: 'GET',
headers: {
'Authorization': 'Bearer deepsy-dev-your-api-key-here'
}
});
const companies: CompanyListResponse = await response.json();
console.log(companies);
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => 'https://deepsy.fr/api/v1/user/companies',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer deepsy-dev-your-api-key-here'
],
]);
$response = curl_exec($curl);
$companies = json_decode($response, true);
curl_close($curl);
print_r($companies);
?>
Response
{
"items": [
{
"company_id": "c193a06f-1c25-4e65-84a7-95faaae7ae7b",
"permissions": ["ADMINISTRATOR", "MANAGE_CAMPAIGN"],
"created_at": "2023-01-01T00:00:00Z",
"updated_at": "2023-01-15T10:30:00Z",
"invitation_code": "ABC12345",
"company": {
"name": "Acme Corporation",
"profile_picture": "https://example.com/company-logo.jpg",
"email": "contact@acme.com",
"website": "https://acme.com",
"industry": "Technology",
"size": "50-100",
"country": "France",
"city": "Paris"
}
}
],
"count": 1
}
Response Fields
Field | Type | Description |
---|---|---|
items | array | List of company memberships |
count | integer | Total number of companies |
Company Membership Object
Each item in the items
array contains:
Field | Type | Description |
---|---|---|
company_id | string (UUID) | Company identifier |
permissions | array | Human-readable list of permissions |
created_at | string | When the user joined this company |
updated_at | string | When the relationship was last updated |
invitation_code | string | Invitation code used to join (nullable) |
company | object | Detailed company information |
Detailed Company Object
Field | Type | Description |
---|---|---|
name | string | Company name |
profile_picture | string | Company profile picture URL (nullable) |
email | string | Company email address (nullable) |
website | string | Company website URL (nullable) |
industry | string | Company industry (nullable) |
size | string | Company size (nullable) |
country | string | Company country (nullable) |
city | string | Company city (nullable) |
Understanding Permissions
Permissions in the /user/me
endpoint are returned as integers (bitfield values), while in /user/companies
they're returned as human-readable strings.
For more information about the permission system, see our Permissions Guide.
Error Responses
401 Unauthorized
{
"error": "API key not provided",
"error_code": "API_KEY_NOT_PROVIDED"
}
500 Internal Server Error
{
"error": "Internal server error"
}
Best Practices
- Cache User Data: User profile information doesn't change frequently, so consider caching the response
- Handle Nullable Fields: Many user profile fields can be null, ensure your application handles this gracefully
- Permission Checking: Always check user permissions before attempting operations on companies
- Company Limits: The
/user/me
endpoint limits companies to 10, use/user/companies
for complete lists
Related Guides
- Authentication Guide - Learn how to set up API keys
- Permissions Guide - Understand the permission system
- Campaign Management Guide - Create and manage campaigns
- Error Handling Guide - Handle API errors effectively