Integrate
Integrate v2
Integrate v2
  • Getting Started
    • 🤝Authorisation & Activation
    • 🔗API v2 URL
    • 🔢Versioning
    • 🔐Authentication
    • 🟰Additional Headers
    • 🆗Response Status Codes
    • 🛑Rate Limiting
    • ⁉️Errors and Bad Requests
    • 📖Pagination
    • ⏭️Upgrading to v2
  • Reference
    • Settings
      • Client Integrations
        • Get Client Integrations
        • Change Client Integration State
    • Finance+
      • Debt Management
        • Debtor Notes
          • Get Communication Type(s)
          • Get Note Type(s)
          • Get Note(s)
          • Create Note
          • Update Note
          • Delete Note
          • Get Promise To Pay Record(s)
          • Delete Promise To Pay
        • Age Analysis Report
        • Financial Transactions Report
        • Get Schools
        • Get Accountable Person(s)
        • Get Learner(s)
        • Get Transaction Type(s)
        • Get Transaction Category(s)
Powered by GitBook
On this page
  • Request Headers
  • Request Body
  • Response Examples
  • Code Samples
  1. Reference
  2. Settings
  3. Client Integrations

Change Client Integration State

POST /v1/settings/clientintegrations

Use this endpoint to change the state of the integration for a client who has authorised your integration in their d6+ SAMS instance. This state indicates whether you are actively servicing the client or not.

Request Headers

Name
Type
Description

HTTP-X-USERNAME*

String

As provided by d6

HTTP-X-PASSWORD*

String

As provided by d6

Request Body

Name
Type
Description

school_id*

Integer

The ID of the school to update

api_type_id*

Integer

The api_type_id returned by the Get Clients endpoint

state*

Boolean

The state you would like to set the integration to

Response Examples

Status: 200 OK

{
    "success": true,
    "message": "Integration successfully activated",
    "data": {
        "school_id": 1000,
        "school_name": "d6+ Primary School",
        "admin_email_address": "support@d6plus.co.za",
        "telephone_calling_code": "27",
        "telephone_number": "0123334444",
        "api_type_id": 8,
        "api_type": "Admin+ API",
        "activated_by_integrator": "Yes" // <-
    }
}

Description: When activating/deactivating the integration when it is already in that state

Status: 400 Bad Request

{
    "success": false,
    "message": "Integration already activated",
    "data": {
        "school_id": 1000,
        "school_name": "d6+ Primary School",
        "admin_email_address": "support@d6plus.co.za",
        "telephone_calling_code": "27",
        "telephone_number": "0123334444",
        "api_type_id": 8,
        "api_type": "Admin+ API",
        "activated_by_integrator": "Yes" // <-
    }
}

Description: This error occurs when attempting to activate an integration for a school that has not authorized your integration. Schools must first authorize the integration before it can be activated by the integrator.

Status: 401 Unauthorized

{
    "success": false,
    "message": "Client has not authorised access"
}

Description: When validation failed for one or more fields

Status: 400 Bad Request

{
    "success": false,
    "message": "Validation Failed",
    "validation_errors": {
        "api_type_id": "The api_type_id is invalid",
        "state": "The State must be a boolean"
    }
}

Code Samples

<?php

// API Endpoint
const BASE_URL = 'https://integrate.d6plus.co.za/api/v2/settings/clientintegrations';

// API Credentials
const API_USERNAME = 'your_username';
const API_PASSWORD = 'your_password';

// Request payload
$data = [
    "school_id"   => 1000,
    "api_type_id" => 8,
    "state"       => 1
];

// Initialize cURL
$curl = curl_init();

// Set cURL options
curl_setopt_array($curl, [
    CURLOPT_URL            => BASE_URL,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_TIMEOUT        => 30,  // Set timeout to prevent hanging requests
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_HTTP_VERSION   => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST  => 'PATCH',
    CURLOPT_POSTFIELDS     => json_encode($data), // Encode array as JSON
    CURLOPT_HTTPHEADER     => [
        "Content-Type: application/json",
        "HTTP-X-USERNAME: " . API_USERNAME,
        "HTTP-X-PASSWORD: " . API_PASSWORD
    ],
]);

// Execute request
$response = curl_exec($curl);

// Check for errors
if (curl_errno($curl)) {
    throw new Exception('Curl error: ' . curl_error($curl));
}

// Close cURL session
curl_close($curl);

// Output response
echo $response;
curl --request PATCH "https://integrate.d6plus.co.za/api/v2/settings/clientintegrations" \
     --header "Content-Type: application/json" \
     --header "HTTP-X-USERNAME: your_username" \
     --header "HTTP-X-PASSWORD: your_password" \
     --data '{
         "school_id": 1000,
         "api_type_id": 8,
         "state": 1
     }'
PreviousGet Client IntegrationsNextFinance+