API Reference
Connect Your Website to DotSquare
The DotSquare API is a PHP only service at this point in time. JSON is returned by all API responses, including errors.
Your API version is directly linked to the version of DotSquare that you are running so be mindful of this when upgrading dotSquare. You will need to FTP and initialize the DotSquare API on your web server each time you update to ensure everything functions properly.
API Library
The official dotSquare library is only available in PHP (version 5.6 or higher).
API EndPoint
https://cms.fiveonedevelopment.com/dotsquare/{API-VERSION}/api/
Authentication
Connect your account by including your DotSquare API key in API requests. You can find your DotSquare API key inside DotSquare. Then visit "Developers" → "Account". When connecting to DotSquare, your API key will also be set.
Example Request
\DotSquare\Initialize::connect({API-KEY});
Setting a New API Key
If you have multiple partitions, each partition has it's own API key. Be sure to use the key that correlates to desired partition. You can reset the API Key for the partition you need by simply calling setApiKey().
Example Request
\DotSquare\DotSquare::setApiKey('ds_HerEub8YjMvGOQmdGf0z');
// New key will now be used for all following requests
The Response Object
All DotSquare API responses output JSON objects.
Attributes
boolean
string
integer
list
list
string
string
Example Request
\DotSquare\Geo::getUSZipData([
'us_zip'=>'92101'
]);
Example Response
DotSquare\Geo JSON: {
'success': true,
'message': 'Success',
'http_code': 200,
'data': {
'city': 'San Diego',
'state': 'US-CA',
'lat': 32.726967,
'lng': -117.164709
},
'error': {
// Error Data will be displayed here in the event of an error.
}
}
Errors
DotSquare uses conventional HTTP response codes to indicates the status of an API request result.
Codes in the 500+ are indicative of a dotSquare error.
HTTP Status Codes
DotSquare Error Types
Handing Errors
DotSquare API returns an array of information including elemnt containing success or failure or the call. You can test the "success" key for a true value to determine the status of the result.
If an error is thrown, you can display further error details inside the "error" array.
Example Request
$response = \DotSquare\Geo::getUSZipData([
'us_zip'=>'92101'
]);
Example Response - Error Handing
if($response->success){
// Do Something ...
} else {
$type = $response->error->type;
$debug = $response->error->debug;
}
Initialize
The first connection to DotSquare
This is the first thing that must be done when setting up a dotSquare website if not using our Framework. The DotSquare Framework natively handles this operation in the init.php file.
Arguments
Required
Data Attributes
list
list
list
int
int
string
string
int
string
string
boolean
Example Request
\DotSquare\Initialize::connect({API-KEY});
Example Response
DotSquare\Initialize JSON: {
'success': true,
'message': 'Success',
'http_code': 200,
'data': {
'database': {
'host': 'fiveonedevelopment.com',
'user': 'myUsername',
'pass': 'myPassword',
'client_db': 'my_db_name',
'client_db_ecomm': 'my_db_name_ecomm',
'db_connection_id': 2,
'db_token': 'db_XXXXXXXXXXXXXX',
},
'account': {
'ecommerce': true,
'tier': 'multi_partition',
},
'paths': {
'ds_path': 'dotsquare/6.64.0/',
'base_url': '/',
'upload_root_path': 'https://cms.fiveonedevelopment.com/',
'upload_base_url': 'https://cms.fiveonedevelopment.com/',
'ds_root_path': 'https://cms.fiveonedevelopment.com/',
'ds_base_url': 'https://cms.fiveonedevelopment.com/',
'gs_base_url': 'https://api.go-spotter.com/'
},
'UTC_timestamp': 1775772856,
'UTC_offset': -8,
'webspace': 'demoWebspace',
'ds_version': '6.64.0',
'cache_token': 'F5TRDKXwvO2MthyzpQ6r',
'partition_id': 1,
'custom_id': 1,
'salt': 'SsWPMPcWkw4BoWXh6AOe',
'cookie_prefix': 'demowebspace-XXXXX',
'time_zone': 'America/Los_Angeles',
'live_mode': true
},
'error': {
// Error Data will be displayed here in the event of an error.
}
}
Analytics
Track Views and Admin Activity
Use this API class to log page views and retrieve admin login history.
Admin Login History
Retrieves login and logout history for one or more admin users. The admins parameter accepts an associative array of admin IDs grouped under custom keys that you define. The custom keys are not used to query data — they are simply passed through to organize the response. The database lookup is performed using only the admin IDs. Results are then returned under the same custom keys you provided, making it easy to group login history by partition, batch, department, or any other label meaningful to your application.
Arguments
Required
Ex. array('partition_5'=>array('1','4','9'), 'partition_12'=>array('44','105'))
Data Attributes
list
int
datetime
datetime
datetime
list
int
datetime
datetime
datetime
Example Request
\DotSquare\Analytics::getAdminLoginHistory([
'admins' => [
'2' => ['1', '4', '9'],
'12' => ['44', '105']
]
]);
Example Response
DotSquare\Analytics JSON: {
'success': true,
'message': 'Success',
'http_code': 200,
'data': {
'history': {
'2': {'admin_id': 9, 'login_datetime': '2025-12-02 10:00:00', 'logout_datetime': null, 'last_visit_datetime': '2025-12-02 11:30:00'},
'12': {'admin_id': 105, 'login_datetime': '2025-12-03 11:20:00', 'logout_datetime': '2025-12-03 18:00:00', 'last_visit_datetime': '2025-12-03 17:55:00'},
},
'last_occurrence': {
'2': {'admin_id': 9, 'login_datetime': '2025-12-02 10:00:00', 'logout_datetime': null, 'last_visit_datetime': '2025-12-02 11:30:00'},
'12': {'admin_id': 105, 'login_datetime': '2025-12-03 11:20:00', 'logout_datetime': '2025-12-03 18:00:00', 'last_visit_datetime': '2025-12-03 17:55:00'},
},
},
'error': {
// Error Data will be displayed here in the event of an error.
}
}
New Page View
Logs a new page view with visitor tracking, traffic source detection, device type, geolocation data, and bot/spam detection. Also tracks daily active users.
Arguments
Required
Required
optional
Required
Required
Required
Required
optional
optional
optional
optional
Example Request
\DotSquare\Analytics::newView([
'partition_id' => 1,
'pseg_id' => 1,
'page_id' => 5,
'page_title' => 'Home',
'http_user_agent' => $_SERVER['HTTP_USER_AGENT'],
'ipv4' => $_SERVER['REMOTE_ADDR'],
'visitor_key' => 'abc123'
]);
Example Response
DotSquare\Analytics JSON: {
'success': true,
'message': 'Success',
'http_code': 200,
'data': {},
'error': {
// Error Data will be displayed here in the event of an error.
}
}
Data
Request Social Media, Custom Fields, and more
Use this API class to easily retrieve curated data from our servers.
Example Request
\DotSquare\Data::getSocialData([
'social_id' => 1
]);
Example Response
DotSquare\Data JSON: {
'success': true,
'message': 'Success',
'http_code': 200,
'data': {
1: {
'site_name': 'Facebook',
'domain': 'Facebook.com',
'icon_name': 'fb',
'category': 'social_media',
}
},
'error': {
// Error Data will be displayed here in the event of an error.
}
}
Custom Fields
DotSquare allows custom fields objects such as Staff, FAQS, etc. This is useful if you need very specific information about an object to be stored. For more information about custom fields visit the Resource Guide
Returns data about all fields used in your website.
Data Attributes
int
list
string
string
Ex. int, varchar, decimal, text, binary, datetime.
int
int
string
Example Request
\DotSquare\Data::getFieldsData([]);
Example Response
DotSquare\Data JSON: {
'success': true,
'message': 'Success',
'http_code': 200,
'data': {
'num_fields': 3,
'fields': {
0: {
'type_title': 'Short Text',
'type': 'varchar',
'max_length': null,
'max_value': null,
'multilingual': 'no',
}
1: /* DotSquare Data */,
2: /* DotSquare Data */
},
},
'error': {
// Error Data will be displayed here in the event of an error.
}
}
Edit Mode
In addition to editing website text directly through the dashboard app, in certain cases, DotSquare also allows admins to change app text (displayed on the website) in edit mode. This can make it more intuitive for admins to edit their website. This is natively included in the DotSquare Framework so no extra coding is required unless you wish to create custom features.
An example is if staff is listed with descriptions and titles. With this API, the bio and title for each staff member can be changed in edit mode.
Learn more about DotSqaure's Page Editor App
Arguments
Required
Data Attributes
string
string
string
boolean
int
Example Request
\DotSquare\Data::getEditModeData([
'col_id' => 1
]);
Example Response
DotSquare\Data JSON: {
'success': true,
'message': 'Success',
'http_code': 200,
'data': {
'table_name': 'cms_staff',
'row_target_name': 'id',
'col_target_name': 'title',
'plain_text': false,
'max_length': null,
},
'error': {
// Error Data will be displayed here in the event of an error.
}
}
Fonts
Retrieves detailed font data from the Google Fonts library. Returns font family info, variants, file URLs, and supported subsets.
Arguments
Required
Data Attributes
int
string
boolean
string
list
list
list
Example Request
\DotSquare\Data::getFontsData([
'font_family' => 'Roboto'
]);
Example Response
DotSquare\Data JSON: {
'success': true,
'message': 'Success',
'http_code': 200,
'data': {
'id': 42,
'font_family': 'Roboto',
'is_google_font': true,
'category': 'sans-serif',
'variants': ['100', '300', 'regular', '500', '700', '900'],
'font_files': {
'regular': 'https://fonts.gstatic.com/s/roboto/v30/...',
},
'subsets': ['latin', 'latin-ext', 'cyrillic'],
},
'error': {
// Error Data will be displayed here in the event of an error.
}
}
Integrations
Retrieves integration configurations including connection keys and settings. Returns all active integrations or a specific one by key.
Arguments
optional
Data Attributes
string
string
string
string
string
list
Example Request
\DotSquare\Data::getIntegrationsData([
'integration_key' => 'google_analytics'
]);
Example Response
DotSquare\Data JSON: {
'success': true,
'message': 'Success',
'http_code': 200,
'data': {
'key': 'google_analytics',
'name': 'Google Analytics',
'category': 'analytics',
'description': 'Track website traffic and user behavior.',
'connection_type': 'api_key',
'connection_keys': {
// Integration-specific keys
},
},
'error': {
// Error Data will be displayed here in the event of an error.
}
}
Site Themes
Retrieves site template theme configurations including styles, CSS values, and associated Google Fonts. Returns all active themes or a specific one by ID.
Arguments
optional
Data Attributes
string
list
list
list
string
string
Example Request
\DotSquare\Data::getSiteThemesData([
'theme_id' => 1
]);
Example Response
DotSquare\Data JSON: {
'success': true,
'message': 'Success',
'http_code': 200,
'data': {
1: {
'theme_ider': 'modern_dark',
'google_fonts': ['Roboto', 'Open Sans'],
'style': {
'values': { /* style variables */ },
'css': '/* compiled CSS */',
'css_usage': '/* usage notes */',
},
},
},
'error': {
// Error Data will be displayed here in the event of an error.
}
}
Organization
Request Information Relevant to the Organization
Use this API class to easily retrieve information about an organizations service areas.
Service Areas
DotSquare allows you to store where a business or organization does business. This is useful in delivery businesses, organizations that have exclusive operations within a geography and more.
You can retrieve all service areas or retrieve a selected service area.
Arguments
optional
optional
optional
Ex. coordinates, zip_code, city, county, state
optional assoc. array
required [1]
required [1]
optional
required [2]
required [3]
required [4]
optional
optional
Ex. distance, zip_code, city, county, state, random.
optional
Data Attributes
int
list
string
string
string
string
decimal
decimal
decimal
Example Request
\DotSquare\Org::getServiceAreas([
'select_by' => 'coordinates',
'select_arguments' => [
'lat'=>32.7211000000,
'lng'=>-117.1743660000
],
'order_by'=>'distance',
'limit'=>40
]);
Example Response
DotSquare\Org JSON: {
'success': true,
'message': 'Success',
'http_code': 200,
'data': {
'num_rows': 40,
'rows': {
0: {
'zip_code': '92101',
'city': 'San Diego',
'county': 'San Diego',
'state': 'California',
'lat': 32.7211000000,
'lng': -117.1743660000,
'distance': 0.1,
},
1: /* DotSquare Data */,
2: /* DotSquare Data */
},
},
'error': {
// Error Data will be displayed here in the event of an error.
}
}
Display
Generate Sitemaps and Display Data
Use this API class to generate sitemaps and retrieve display-related data.
Site Map
Generates both HTML and XML sitemaps for the current partition. Includes pages, posts, blog entries, gallery items, portfolio items, batches, tags, and service areas.
Data Attributes
string
string
Example Request
\DotSquare\Display::getSiteMap([]);
Example Response
DotSquare\Display JSON: {
'success': true,
'message': 'Success',
'http_code': 200,
'data': {
'html': '',
'xml': '...',
},
'error': {
// Error Data will be displayed here in the event of an error.
}
}
Files
Upload, Move, and Delete Files
Use this API class to manage file uploads, deletions, and file operations on the CMS.
Delete File
Deletes a file from the upload directory.
Arguments
Required
Example Request
\DotSquare\Files::deleteFile([
'file_path' => 'images/old_photo.jpg'
]);
Example Response
DotSquare\Files JSON: {
'success': true,
'message': 'Success',
'http_code': 200,
'data': {},
'error': {
// Error Data will be displayed here in the event of an error.
}
}
Move File
Moves or renames a file within the upload directory.
Arguments
Required
Required
Example Request
\DotSquare\Files::moveFile([
'from_file_path' => 'images/photo.jpg',
'to_file_path' => 'images/archive/photo.jpg'
]);
Example Response
DotSquare\Files JSON: {
'success': true,
'message': 'Success',
'http_code': 200,
'data': {},
'error': {
// Error Data will be displayed here in the event of an error.
}
}
Upload File
Uploads a document file to the CMS. Supports images, PDFs, Office documents, CSV, and text files.
Arguments
Required
optional
Data Attributes
string
string
string
Example Request
\DotSquare\Files::uploadDocument([
'directory' => 'documents/invoices',
'size_limit' => 10
]);
Example Response
DotSquare\Files JSON: {
'success': true,
'message': 'Success',
'http_code': 200,
'data': {
'file_name': 'invoice_2024.pdf',
'file_category': 'document',
'file_type': 'pdf',
},
'error': {
// Error Data will be displayed here in the event of an error.
}
}
Upload Image
Uploads an image file and automatically creates resized versions (large, medium, small).
Arguments
Required
optional
Data Attributes
string
decimal
Example Request
\DotSquare\Files::uploadImage([
'directory' => 'images/products',
'size_limit' => 5
]);
Example Response
DotSquare\Files JSON: {
'success': true,
'message': 'Success',
'http_code': 200,
'data': {
'file_name': 'product_photo.jpg',
'H2W_ratio': 0.75,
},
'error': {
// Error Data will be displayed here in the event of an error.
}
}
Geo
Geographic and Location Data
Use this API class to retrieve geographic data such as IP geolocation, US zip code info, sales tax rates, and time zones.
Get IP Data
Retrieves geolocation data for an IP address using the ipstack API. Includes bot and spam detection.
Arguments
Required
Required
optional
optional
Data Attributes
string
string
string
string
decimal
decimal
Example Request
\DotSquare\Geo::getIpData([
'ip' => '134.201.250.155',
'access_key' => 'YOUR_IPSTACK_KEY'
]);
Example Response
DotSquare\Geo JSON: {
'success': true,
'message': 'Success',
'http_code': 200,
'data': {
'city': 'Los Angeles',
'region_name': 'California',
'country_name': 'United States',
'zip': '90012',
'latitude': 34.0655,
'longitude': -118.2405,
},
'error': {
// Error Data will be displayed here in the event of an error.
}
}
Get US Sales Tax
Retrieves the sales tax rate for a given US zip code.
Arguments
Required
Data Attributes
decimal
Example Request
\DotSquare\Geo::getUSSalesTax([
'us_zip' => '92101'
]);
Example Response
DotSquare\Geo JSON: {
'success': true,
'message': 'Success',
'http_code': 200,
'data': {
'sales_tax_rate': 0.0775,
},
'error': {
// Error Data will be displayed here in the event of an error.
}
}
Get US Time Zone
Retrieves the UTC offset for a given US zip code.
Arguments
Required
Data Attributes
int
Example Request
\DotSquare\Geo::getUSTimeZone([
'us_zip' => '92101'
]);
Example Response
DotSquare\Geo JSON: {
'success': true,
'message': 'Success',
'http_code': 200,
'data': {
'utc_offset': -8,
},
'error': {
// Error Data will be displayed here in the event of an error.
}
}
Get US Zip Data
Retrieves city, county, state, and coordinates for a given US zip code.
Arguments
Required
Data Attributes
string
string
string
decimal
decimal
Example Request
\DotSquare\Geo::getUSZipData([
'us_zip' => '92101'
]);
Example Response
DotSquare\Geo JSON: {
'success': true,
'message': 'Success',
'http_code': 200,
'data': {
'city': 'San Diego',
'county': 'San Diego',
'state': 'California',
'lat': 32.726967,
'lng': -117.164709,
},
'error': {
// Error Data will be displayed here in the event of an error.
}
}
Notifications
Send Emails, SMS, and Check Spam
Use this API class to send emails, bulk emails, SMS messages, and evaluate submissions for spam.
Get Spam Filter
Evaluates a submission for spam by analyzing the submitter's email, phone, comments, and visitor key. Returns a spam index score.
Arguments
optional
optional
optional
optional
Data Attributes
int
Example Request
\DotSquare\Notifications::getSpamFilter([
'submitters_email' => 'user@example.com',
'comments' => ['Great service!'],
'visitor_key' => 'abc123'
]);
Example Response
DotSquare\Notifications JSON: {
'success': true,
'message': 'Success',
'http_code': 200,
'data': {
'spam_index': 2,
},
'error': {
// Error Data will be displayed here in the event of an error.
}
}
Send Bulk Emails
Sends personalized emails to multiple recipients via Mailgun. Each recipient can have unique template variable replacements.
Arguments
Required
Required
Required
optional
optional
Example Request
\DotSquare\Notifications::sendBulkEmails([
'subject' => 'Monthly Newsletter',
'body' => 'Hello [[name]]!
',
'recipients_w_variables_arr' => [
'john@example.com' => ['name' => 'John'],
'jane@example.com' => ['name' => 'Jane'],
]
]);
Example Response
DotSquare\Notifications JSON: {
'success': true,
'message': 'Success',
'http_code': 200,
'data': {},
'error': {
// Error Data will be displayed here in the event of an error.
}
}
Send Email
Sends an email to one or more recipients. Supports custom templates, attachments, and template variable replacements.
Arguments
Required
Required
Required
optional
optional
optional
optional
optional
Example Request
\DotSquare\Notifications::sendEmail([
'subject' => 'Welcome!',
'body' => 'Welcome to our platform.
',
'recipients' => ['user@example.com'],
'from_name' => 'My Company'
]);
Example Response
DotSquare\Notifications JSON: {
'success': true,
'message': 'Success',
'http_code': 200,
'data': {},
'error': {
// Error Data will be displayed here in the event of an error.
}
}
Send SMS
Sends an SMS text message to one or more phone numbers via Clickatell.
Arguments
Required
Required
Example Request
\DotSquare\Notifications::sendSMS([
'recipients' => ['16195551234'],
'body' => 'Your order has shipped!'
]);
Example Response
DotSquare\Notifications JSON: {
'success': true,
'message': 'Success',
'http_code': 200,
'data': {},
'error': {
// Error Data will be displayed here in the event of an error.
}
}
Users
Payment Methods and Subscriptions
Use this API class to manage user payment cards, bank accounts, and payment subscriptions.
Create Payment Subscription
Creates a new payment subscription for a billing contact. Provide a plan_id to use a pre-configured plan (trial period comes from the plan), or omit it and provide custom_plan_info to create a custom subscription with manual details.
Arguments
Required
conditional
optional
optional
optional
optional
optional
optional
conditional
Required
Required
Required
Required
optional
optional
optional
optional
Data Attributes
int
string
int
array
Example Request
// Plan-based subscription (trial comes from the plan)
\DotSquare\Users::createPaymentSubscription([
'contact_id' => 42,
'plan_id' => 3,
'details' => [
'auto_pay' => 1,
'pay_time' => 'pre',
'notify' => 1
]
]);
// Custom subscription (no plan)
\DotSquare\Users::createPaymentSubscription([
'contact_id' => 42,
'details' => [
'auto_pay' => 1,
'notify' => 1
],
'custom_plan_info' => [
'title' => 'Monthly Retainer',
'comment' => 'Ongoing consulting services',
'interval_count' => 1,
'interval' => 'month',
'initial_fee' => '50.00',
'trial_days' => 7,
'items' => [
['item_id' => 10, 'qty' => 1, 'price' => '200.00'],
['item_id' => 15, 'qty' => 2]
]
]
]);
Example Response
DotSquare\Users JSON: {
'success': true,
'message': 'Success',
'http_code': 200,
'data': {
'subscription_id': 78,
'subscription_GUID': 'sub_a1b2c3d4e5f67890abcd',
'subscription_schedule_id': 12,
'first_invoice': [],
},
'error': {
// Error Data will be displayed here in the event of an error.
}
}
Cancel Payment Subscription
Cancels an active subscription. The subscription will remain active until the end of the current billing period, after which it will stop. The subscription can be restarted before it ends.
Arguments
Required
Data Attributes
int
string
Example Request
\DotSquare\Users::cancelPaymentSubscription([
'subscription_GUID' => 'sub_a1b2c3d4e5f67890abcd'
]);
Example Response
DotSquare\Users JSON: {
'success': true,
'message': 'Success',
'http_code': 200,
'data': {
'subscription_id': 78,
'subscription_GUID': 'sub_a1b2c3d4e5f67890abcd',
},
'error': {
// Error Data will be displayed here in the event of an error.
}
}
Restart Payment Subscription
Restarts a canceled subscription. If the subscription has not yet ended, the cancellation is reversed and no invoice is created. If the subscription has already ended, a new subscription is created as a copy of the original and an invoice/order is generated immediately (based on auto-pay settings).
Arguments
Required
optional
Data Attributes
int
string
int
object
Example Request
\DotSquare\Users::restartPaymentSubscription([
'subscription_GUID' => 'sub_a1b2c3d4e5f67890abcd',
'allow_bill_immediately' => 1
]);
Example Response
DotSquare\Users JSON: {
'success': true,
'message': 'Success',
'http_code': 200,
'data': {
'subscription_id': 78,
'subscription_GUID': 'sub_x9y8z7w6v5u43210mnop',
'subscription_plan_id': 46,
'first_invoice': { ... },
},
'error': {
// Error Data will be displayed here in the event of an error.
}
}
Change Payment Subscription
Changes an active subscription from one plan to another. Upgrades (new plan price ≥ current) are applied immediately with proration. Downgrades (new plan price < current) are deferred — the current plan stays active until the next billing cycle, when it automatically swaps to the new plan. Cancel pending change — if the subscription has a pending plan change and you pass the current plan's ID as new_plan_id, the pending change is cancelled and the subscription stays on the current plan. Only plan-based subscriptions can be changed (not custom subscriptions).
Arguments
Required
Required
optional
optional
optional
Data Attributes
int
string
string
int
int
string
object
float
float
float
float
float
object
int
Example Request
// Upgrade example
\DotSquare\Users::changePaymentSubscription([
'subscription_GUID' => 'sub_a1b2c3d4e5f67890abcd',
'new_plan_id' => 5,
]);
// Downgrade example (deferred to next billing cycle)
\DotSquare\Users::changePaymentSubscription([
'subscription_GUID' => 'sub_a1b2c3d4e5f67890abcd',
'new_plan_id' => 1,
]);
// Cancel a pending plan change (pass the current plan ID)
\DotSquare\Users::changePaymentSubscription([
'subscription_GUID' => 'sub_a1b2c3d4e5f67890abcd',
'new_plan_id' => 5, // the plan the subscription is already on
]);
// Upgrade with a new discount, no proration
\DotSquare\Users::changePaymentSubscription([
'subscription_GUID' => 'sub_a1b2c3d4e5f67890abcd',
'new_plan_id' => 5,
'discount_id' => 12,
'allow_proration' => 0,
]);
Example Response
// Upgrade response
DotSquare\Users JSON: {
'success': true,
'message': 'Success',
'http_code': 200,
'data': {
'subscription_id': 78,
'subscription_GUID': 'sub_a1b2c3d4e5f67890abcd',
'change_type': 'upgrade',
'old_plan_id': 1,
'new_plan_id': 5,
'effective_date': '2026-03-25 14:30:00',
'proration': {
'credit': 12.50,
'charge': 25.00,
'net': 12.50,
'days_remaining': 15,
'days_in_cycle': 30,
},
'proration_invoice': {
'invoice_id': 234,
},
},
'error': {
// Error Data will be displayed here in the event of an error.
}
}
// Downgrade response
DotSquare\Users JSON: {
'success': true,
'message': 'Success',
'http_code': 200,
'data': {
'subscription_id': 78,
'subscription_GUID': 'sub_a1b2c3d4e5f67890abcd',
'change_type': 'downgrade',
'old_plan_id': 5,
'new_plan_id': 1,
'effective_date': '2026-04-25 00:00:00',
},
'error': {
// Error Data will be displayed here in the event of an error.
}
}
// Cancel pending change response
DotSquare\Users JSON: {
'success': true,
'message': 'Pending plan change cancelled.',
'http_code': 200,
'data': {
'subscription_id': 78,
'subscription_GUID': 'sub_a1b2c3d4e5f67890abcd',
'change_type': 'cancel_pending',
'old_plan_id': 5,
'new_plan_id': 5,
},
'error': {
// Error Data will be displayed here in the event of an error.
}
}
Create Bank Account
Creates a bank account record for a user or user group. The account must be verified before it can be used for payments.
Arguments
optional
optional
Required
Required
Required
Required
Required
optional
optional
optional
Data Attributes
string
Example Request
\DotSquare\Users::createUserBankAccount([
'user_id' => 15,
'data' => [
'holder_name' => 'John Doe',
'holder_type' => 'individual',
'routing_number' => '110000000',
'account_number' => '000123456789',
'make_default' => true
]
]);
Example Response
DotSquare\Users JSON: {
'success': true,
'message': 'Success',
'http_code': 200,
'data': {
'method_token': 'ba_9f8e7d6c5b4a3210',
},
'error': {
// Error Data will be displayed here in the event of an error.
}
}
Create Card
Creates a payment card record for a user or user group using a payment gateway token.
Arguments
Required
optional
optional
optional
Data Attributes
string
Example Request
\DotSquare\Users::createUserCard([
'token' => 'tok_XXXXXXXXXXXXXX',
'user_id' => 15,
'make_default' => true
]);
Example Response
DotSquare\Users JSON: {
'success': true,
'message': 'Success',
'http_code': 200,
'data': {
'method_token': 'card_3a4b5c6d7e8f9012',
},
'error': {
// Error Data will be displayed here in the event of an error.
}
}
Default Bank Account
Sets a bank account as the default payment method for the user.
Arguments
Required
Example Request
\DotSquare\Users::defaultUserBankAccount([
'method_token' => 'ba_XXXXXXXXXXXXXX'
]);
Example Response
DotSquare\Users JSON: {
'success': true,
'message': 'Success',
'http_code': 200,
'data': {},
'error': {
// Error Data will be displayed here in the event of an error.
}
}
Default Card
Sets a card as the default payment method for the user.
Arguments
Required
Example Request
\DotSquare\Users::defaultUserCard([
'method_token' => 'card_XXXXXXXXXXXXXX'
]);
Example Response
DotSquare\Users JSON: {
'success': true,
'message': 'Success',
'http_code': 200,
'data': {},
'error': {
// Error Data will be displayed here in the event of an error.
}
}
Ecommerce
Carts, Orders, Payments, and Subscriptions
Use this API class to manage shopping carts, create orders, process payments, and handle subscriptions.
Create Cart Invoice
Creates an invoice from a shopping cart. Handles item totals, tax calculations, and optional transaction processing.
Arguments
Required
Required
Required
optional
optional
optional
Required
Required
Required
optional
Data Attributes
int
string
Example Request
\DotSquare\Ecommerce::createCartInvoice([
'cart_token' => 'cart_XXXXXXXXXXXXXX',
'contact_id' => 42,
'loc_id' => 1,
'invoice' => [
'title' => 'Order #1001',
'type_id' => 1,
'fulfillment_method_id' => 2,
'comment' => 'Rush delivery'
]
]);
Example Response
DotSquare\Ecommerce JSON: {
'success': true,
'message': 'Success',
'http_code': 200,
'data': {
'invoice_id': 1001,
'invoice_key': 'inv_a1b2c3d4-e5f6-7890-abcd-ef1234567890',
},
'error': {
// Error Data will be displayed here in the event of an error.
}
}
Create Order
Creates a full order from a shopping cart including invoice creation and payment processing. Supports guest checkout.
Arguments
Required
optional
optional
optional
optional
optional
optional
optional
optional
optional
optional
Data Attributes
int
int
Example Request
\DotSquare\Ecommerce::createOrder([
'cart_token' => 'cart_XXXXXXXXXXXXXX',
'payment_token' => 'tok_XXXXXXXXXXXXXX',
'guest_info' => [
'email' => 'guest@example.com',
'name_first' => 'John',
'name_last' => 'Doe'
]
]);
Example Response
DotSquare\Ecommerce JSON: {
'success': true,
'message': 'Success',
'http_code': 200,
'data': {
'invoice_id': 1002,
'transaction_id': 5501,
},
'error': {
// Error Data will be displayed here in the event of an error.
}
}
Create Payment Token
Creates a temporary payment token for a card or bank account. Used to securely process payments without storing raw payment details.
Arguments
Required
optional
optional
optional
optional
optional
optional
conditional
Required
Required
Required
Required
Required
conditional
Required
Required
Required
Data Attributes
string
Example Request
\DotSquare\Ecommerce::createPaymentToken([
'method_type' => 'card',
'card' => [
'holder_name' => 'John Doe',
'number' => '4242424242424242',
'exp_month' => 12,
'exp_year' => 2027,
'cvc' => '123'
],
'address' => [
'postal_code' => '92101'
]
]);
Example Response
DotSquare\Ecommerce JSON: {
'success': true,
'message': 'Success',
'http_code': 200,
'data': {
'token': 'tok_XXXXXXXXXXXXXX',
},
'error': {
// Error Data will be displayed here in the event of an error.
}
}
Create Return
Processes a return for one or more order items. Optionally processes a refund.
Arguments
Required
Required
Required
Required
optional
optional
Data Attributes
list
decimal
Example Request
\DotSquare\Ecommerce::createReturn([
'items' => [
[
'invoice_item_row_id' => 101,
'fulfillment_row_id' => 55,
'new_qty' => 1
]
],
'process_refund' => true
]);
Example Response
DotSquare\Ecommerce JSON: {
'success': true,
'message': 'Success',
'http_code': 200,
'data': {
'return_row_ids': [201],
'return_amount': 29.99,
},
'error': {
// Error Data will be displayed here in the event of an error.
}
}
Create Subscription Invoice
Creates an invoice for a subscription billing cycle. Handles pending plan downgrades before invoicing.
Arguments
Required
Data Attributes
object
string
int
string
string
float
object
int
float
object
int
float
Example Request
\DotSquare\Ecommerce::createSubscriptionInvoice([
'token' => 'sub_XXXXXXXXXXXXXX'
]);
Example Response
DotSquare\Ecommerce JSON: {
'success': true,
'message': 'Success',
'http_code': 200,
'data': {
'invoice': {
'partition_id': '12',
'invoice_id': 1015,
'invoice_token': 'inv_f9e8d7c6b5a43210fedc',
'invoice_number': 'INV-001015',
'total': 49.99,
},
'credit_transaction': {
'trans_id': 401,
'total': 10.00,
},
'transaction': {
'trans_id': 402,
'total': 39.99,
},
},
'error': {
// Error Data will be displayed here in the event of an error.
}
}
Create Transaction
Creates a payment transaction record. Can be associated with invoices and includes notification options.
Arguments
Required
optional
optional
optional
optional
optional
optional
optional
Data Attributes
int
Example Request
\DotSquare\Ecommerce::createTransaction([
'contact_id' => 42,
'transaction_amount' => 99.99,
'invoice_id' => 1001,
'method_id' => 3,
'notify_payer' => true
]);
Example Response
DotSquare\Ecommerce JSON: {
'success': true,
'message': 'Success',
'http_code': 200,
'data': {
'transaction_id': 5502,
},
'error': {
// Error Data will be displayed here in the event of an error.
}
}
Get Cart
Retrieves full cart details including items, contact info, payment method, and address.
Arguments
Required
optional
Data Attributes
list
list
list
list
Example Request
\DotSquare\Ecommerce::getCart([
'token' => 'cart_XXXXXXXXXXXXXX'
]);
Example Response
DotSquare\Ecommerce JSON: {
'success': true,
'message': 'Success',
'http_code': 200,
'data': {
'items': [
{'item_id': 201, 'title': 'Blue T-Shirt', 'qty': 2, 'price': 24.99},
{'item_id': 305, 'title': 'Running Shoes', 'qty': 1, 'price': 89.99},
],
'contact': {
'contact_id': 42,
'name_first': 'John',
'name_last': 'Doe',
'email': 'john@example.com',
},
'method': {
'method_token': 'card_3a4b5c6d7e8f9012',
'type': 'card',
'last4': '4242',
'brand': 'Visa',
},
'address': {
'street': '123 Main St',
'city': 'San Diego',
'subdivision': 'US-CA',
'postal_code': '92101',
'country': 'US',
},
},
'error': {
// Error Data will be displayed here in the event of an error.
}
}
Get Cart Totals
Calculates and returns the totals for a cart including base price, modifiers, discounts, subtotal, tax, gateway fees, and grand total.
Arguments
Required
optional
optional
optional
Data Attributes
decimal
decimal
decimal
decimal
decimal
decimal
decimal
Example Request
\DotSquare\Ecommerce::getCartTotals([
'token' => 'cart_XXXXXXXXXXXXXX',
'location_id' => 1
]);
Example Response
DotSquare\Ecommerce JSON: {
'success': true,
'message': 'Success',
'http_code': 200,
'data': {
'base': 89.97,
'modifiers': 5.00,
'discounts': -10.00,
'subtotal': 84.97,
'tax': 6.59,
'gateway_fees': 0,
'total': 91.56,
},
'error': {
// Error Data will be displayed here in the event of an error.
}
}
Get Payment Token
Retrieves the details of a previously created payment token including card or bank account information.
Arguments
Required
Data Attributes
string
list
list
list
Example Request
\DotSquare\Ecommerce::getPaymentToken([
'token' => 'tok_XXXXXXXXXXXXXX'
]);
Example Response
DotSquare\Ecommerce JSON: {
'success': true,
'message': 'Success',
'http_code': 200,
'data': {
'method_type': 'card',
'address': {
'postal_code': '92101',
},
'card': {
'holder_name': 'John Doe',
'last4': '4242',
'brand': 'Visa',
'exp_month': 12,
'exp_year': 2027,
},
},
'error': {
// Error Data will be displayed here in the event of an error.
}
}
Get Subscription
Retrieves subscription details including plan info, items, and calculated totals.
Arguments
Required
Data Attributes
list
list
decimal
decimal
decimal
decimal
decimal
decimal
decimal
Example Request
\DotSquare\Ecommerce::getSubscription([
'token' => 'sub_XXXXXXXXXXXXXX'
]);
Example Response
DotSquare\Ecommerce JSON: {
'success': true,
'message': 'Success',
'http_code': 200,
'data': {
'plan': {
'plan_id': 3,
'name': 'Pro Monthly',
'billing_cycle': 'monthly',
},
'items': [
{'item_id': 10, 'title': 'Pro Plan License', 'qty': 1, 'price': 49.99},
{'item_id': 11, 'title': 'Additional User Seat', 'qty': 2, 'price': 9.99},
],
'base': 69.97,
'extras': 0,
'discounts': -10.00,
'subtotal': 59.97,
'tax': 4.65,
'total': 64.62,
'gateway_fees': 0,
},
'error': {
// Error Data will be displayed here in the event of an error.
}
}
UPC
Universal Product Code Lookup
Use this API class to look up product data by barcode (UPC, EAN, ISBN).
Get Item from UPC
Looks up product data by barcode. Supports UPC, EAN, ISBN-10, ISBN-13, ASIN, Model, and MPN identifiers. Returns product title, categories, brand, description, attributes, and images.
Arguments
Required
optional
Data Attributes
string
string
string
list
list
list
Example Request
\DotSquare\UPC::getItemFromUPC([
'barcode' => '012345678901'
]);
Example Response
DotSquare\UPC JSON: {
'success': true,
'message': 'Success',
'http_code': 200,
'data': {
'title': 'Example Product',
'brand': 'Example Brand',
'description': 'A great product.',
'categories': ['Electronics', 'Accessories'],
'identifiers': {
'upc': '012345678901',
'ean': '0012345678901',
},
'images': ['https://example.com/image.jpg'],
},
'error': {
// Error Data will be displayed here in the event of an error.
}
}
Shipping
Calculate Shipping Rates
Use this API class to calculate USPS domestic shipping rates and dynamic shipping costs.
Get Dynamic Shipping Cost
Calculates combined shipping cost from multiple items based on dimensions, weight, origin, and destination.
Arguments
Required
Required
Required
Required
Required
Required
Required
Required
Data Attributes
decimal
string
Example Request
\DotSquare\Shipping::getDynamicShippingCost([
'delivery_speed_code' => '3-5',
'origin_zip' => '92101',
'destination_zip' => '07416',
'items' => [
['height'=>6, 'width'=>4, 'length'=>8, 'weight'=>2],
['height'=>12, 'width'=>10, 'length'=>10, 'weight'=>5]
]
]);
Example Response
DotSquare\Shipping JSON: {
'success': true,
'message': 'Success',
'http_code': 200,
'data': {
'rate': 18.75,
'service': 'Priority Mail',
},
'error': {
// Error Data will be displayed here in the event of an error.
}
}
Get USPS Domestic Rate
Retrieves USPS domestic shipping rates for a single package based on dimensions, weight, and delivery speed.
Arguments
Required
Required
Required
optional
optional
optional
optional
optional
Data Attributes
decimal
string
Example Request
\DotSquare\Shipping::getUSPSDomesticRate([
'delivery_speed_code' => '3-5',
'origin_zip' => '92101',
'destination_zip' => '10001',
'weight_pounds' => 3,
'height' => 8,
'width' => 6,
'length' => 10
]);
Example Response
DotSquare\Shipping JSON: {
'success': true,
'message': 'Success',
'http_code': 200,
'data': {
'rate': 12.40,
'service': 'Priority Mail',
},
'error': {
// Error Data will be displayed here in the event of an error.
}
}
Partitions
Create and Manage Partitions
Use this API class to create new partitions and their directory structures for multi-partition setups.
Create Partition
Creates a new partition with organization, admin user, location, and optional billing/payment gateway setup. Automatically creates the partition directory structure.
Arguments
Required
Required
Required
optional
optional
optional
optional
optional
optional
optional
Required
Required
Required
Required
optional
Data Attributes
int
int
Example Request
\DotSquare\Partitions::createPartition([
'org_name' => 'My New Shop',
'partition' => [
'partition_type_id' => 2,
'active' => 1,
'approved' => 1,
'slug' => 'my-new-shop'
],
'admin' => [
'email' => 'admin@mynewshop.com',
'password' => 'securePassword123',
'name_first' => 'John',
'name_last' => 'Doe'
]
]);
Example Response
DotSquare\Partitions JSON: {
'success': true,
'message': 'Success',
'http_code': 200,
'data': {
'partition_id': 5,
'admin_id': 102,
},
'error': {
// Error Data will be displayed here in the event of an error.
}
}
Create Partition Directory
Creates the full upload directory structure for a partition including folders for admins, batches, cache, calendar, documents, ecommerce, and more.
Note: This is already created inside the createPartition API if you are using that.
Arguments
Required
Example Request
\DotSquare\Partitions::createPartitionDirectory([
'id' => 5
]);
Example Response
DotSquare\Partitions JSON: {
'success': true,
'message': 'Success',
'http_code': 200,
'data': {},
'error': {
// Error Data will be displayed here in the event of an error.
}
}