Doc Partner
SMS Partner
Doc Partner - EN
Doc Partner - EN
  • Welcome
  • API
    • SMS Partner
      • Credits
      • Send SMS
        • Single Send
        • Bulk Send
        • Send by Long Number
        • Survey Send
        • Cancel Scheduled SMS
        • Special Characters
      • Status & Statistics
        • Single Status
        • Bulk Status
        • Status by Message
        • Status by Tag
        • Sending Statistics
      • Contact Management
        • Add Group
        • Add Contact
        • Delete Group
        • Add Bulk Contacts
        • Edit Contact
        • Delete Contact
        • Get Group List
        • Get Contact List
        • Get Contact Details
      • Replies / Opt-outs Management
        • Stop List
        • Add Number to SMS Stop List
        • Remove Number from SMS Stop List
        • Replies Management
      • Sub-accounts
        • Activation
        • Create Sub-account
        • Delete Sub-account
        • Sub-account List
        • Manage Sub-account Credits
      • Manage Call Forwarding
      • Number Verification
        • Send a Verification
        • Format Verification
      • Contact Rental
        • Categories
        • Targeting & Calculation
        • Rental Status
        • Download File
      • RCS
    • Error Codes
Powered by GitBook

© 2025 NDA Media

On this page
  • Add Credits
  • URL
  • Remove Credits
  • URL
  1. API
  2. SMS Partner
  3. Sub-accounts

Manage Sub-account Credits

This request is used to manage sub-account credits.

Add Credits

From your main account, you can add credits to your sub-accounts. The credits will be deducted from your main account.

URL

POST https://api.smspartner.fr/v1/subaccount/credit/add

Required Parameters

Name
Value

apiKey

credit

Amount of credit in Euros to add to the sub-account

tokenSubaccount

Sub-account identifier

Requests

<?php
        // Prepare data for POST request
        $fields = array(
            'apiKey'=> 'YOUR API KEY',
            'credit'=> '100',
            'tokenSubaccount'=>'identifiant du sous-compte'
            );
 
 
        $curl = curl_init();
        curl_setopt($curl, CURLOPT_URL,'https://api.smspartner.fr/v1/subaccount/credit/add');
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($curl, CURLOPT_TIMEOUT, 10);
        curl_setopt($curl, CURLOPT_POST, 1);
        curl_setopt($curl, CURLOPT_POSTFIELDS,json_encode($fields));
 
        $result = curl_exec($curl);
        curl_close($curl);
 
        // Process your response here
        echo $result;
?>
Imports System.IO
Imports System.Net
 
Module Module1
 
  Sub Main()
 
    Dim base_url As String = "http://api.smspartner.fr/v1/"
    Dim apiKey As String = "VOTRE_APIKEY"
 
    #send sms
    url = base_url & "subaccount/credit/add"
    #note : utiliser une librairie JSON en production, par exemple :
    #https//www.nuget.org/packages/Newtonsoft.Json/
    Dim parameters As String = String.Format(
        "{{""apiKey"":""{0}"",""credit"":""{1}"",""tokenSubaccount"":""{2}""}}",
        apiKey,
        50,
        "identifiant du sous-compte")
    Console.Write(parameters)
    apiRequest("POST", url, parameters)
 
  End Sub
 
  Function apiRequest(method As String, url As String, parameters As String) As String
 
    Dim request As HttpWebRequest
    request = WebRequest.Create(url)
    request.Method = method
    request.Timeout = 10000   # timeout in ms
    request.ContentType = "application/json; charset=utf-8"
    request.ContentLength = 0
 
    #set POST data
    If Not String.IsNullOrEmpty(parameters) Then
      request.ContentLength = parameters.Length
      Using reqStream As StreamWriter = New StreamWriter(request.GetRequestStream())
        reqStream.Write(parameters)
      End Using
    End If
 
    #get response
    Dim returnValue As String = Nothing
    Using response As HttpWebResponse = request.GetResponse()
      If response.StatusCode = HttpStatusCode.OK Then
        Using resStream = response.GetResponseStream()
          If resStream IsNot Nothing Then
            Using reader As New StreamReader(resStream)
              returnValue = reader.ReadToEnd()
            End Using
          End If
        End Using
      End If
    End Using
    apiRequest = returnValue
 
  End Function
 
End Module
# std
import logging
import json
from collections import OrderedDict
 
# 3p
import requests
 
API_KEY = "MY API KEY"
URL = "https://api.smspartner.fr/v1"
 
class SMSPartner():
    def add_credit(self,creditToAdd,tokenSubaccount):
 
		data = OrderedDict([
			("apiKey", API_KEY),
			("credit",creditToAdd),
			("tokenSubaccount",tokenSubaccount)
 
		])
 
		url = URL + "/subaccount/credit/add"
		r = requests.post(url, data=json.dumps(data), verify=False)
 
		r_json = r.json()
		if r_json.get("success") == True:
			print(r_json)
			status = True
		else:
			print(r_json)
			status = False
		return status
curl -H  "Content-Type: application/json" -X POST -d '{"apiKey":"xxxxx","credit":"10","tokenSubaccount":"identifiant du sous-compte"}' https://api.smspartner.fr/v1/subaccount/credit/add
const https = require('https');

// permet d'ajouter des crédits à un sous-compte
//Depuis votre compte, il vous est possible d’ajouter des crédits sur vos sous comptes. Les crédits seront débités de votre compte principal.
let data = JSON.stringify({
  apiKey: 'YOUR API KEY',
  credit: '100',
  tokenSubaccount: 'identifiant du sous-compte'
});

let options = {
  hostname: 'api.smspartner.fr',
  path: '/v1/subaccount/credit/add',
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Content-Length': data.length
  }
};

let req = https.request(options, (res) => {
  let data = '';

  res.on('data', (chunk) => {
    data += chunk;
  });

  res.on('end', () => {
    console.log(JSON.parse(data));
  });

}).on("error", (err) => {
  console.log("Error: " + err.message);
});

req.write(data);
req.end();
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;

public class AjouterRetirerDesCredits {
    public static void main(String[] args) {
        try {
            // Prepare data for POST request
            String apiKey = "YOUR API KEY";
            int credit = 100;
            String tokenSubaccount = "identifiant du sous-compte";

            // Create JSON payload
            String jsonPayload = "{\"apiKey\": \"" + apiKey + "\", \"credit\": " + credit + ", \"tokenSubaccount\": \"" + tokenSubaccount + "\"}";

            // Create POST request
            URL url = new URL("https://api.smspartner.fr/v1/subaccount/credit/add");
            HttpURLConnection connection = (HttpURLConnection) url.openConnection();
            connection.setRequestMethod("POST");
            connection.setRequestProperty("Content-Type", "application/json");
            connection.setDoOutput(true);

            // Send POST request
            OutputStream outputStream = connection.getOutputStream();
            outputStream.write(jsonPayload.getBytes());
            outputStream.flush();
            outputStream.close();

            // Get response
            int responseCode = connection.getResponseCode();
            BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
            StringBuilder response = new StringBuilder();
            String line;
            while ((line = reader.readLine()) != null) {
                response.append(line);
            }
            reader.close();

            // Process your response here
            System.out.println(response.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
import SwiftUI

struct AjoutCreditSousCompte: View {
    @State private var result: String = "Loading..."

    var body: some View {
        VStack {
            Text("Ajout Credit Sous Compte")
                .font(.title)
                .padding()

            Text(result)
                .font(.system(size: 20))
                .padding()
        }
        .onAppear(perform: ajoutCreditSousCompte)
    }

    func ajoutCreditSousCompte() {
        let apiKey = "YOUR_API_KEY"
        let credit = "100"
        let tokenSubaccount = "identifiant du sous-compte"

        let urlString = "https://api.smspartner.fr/v1/subaccount/credit/add"
        let url = URL(string: urlString)!

        var request = URLRequest(url: url)
        request.httpMethod = "POST"
        request.addValue("application/json", forHTTPHeaderField: "Content-Type")

        let parameters: [String: Any] = [
            "apiKey": apiKey,
            "credit": credit,
            "tokenSubaccount": tokenSubaccount
        ]

        request.httpBody = try? JSONSerialization.data(withJSONObject: parameters)

        let task = URLSession.shared.dataTask(with: request) { (data, response, error) in
            if let error = error {
                print("Error: \(error)")
            } else if let data = data {
                let resultString = String(data: data, encoding: .utf8)
                DispatchQueue.main.async {
                    self.result = resultString ?? "Error"
                }
            }
        }

        task.resume()
    }
}

struct AjoutCreditSousCompte_Previews: PreviewProvider {
    static var previews: some View {
        AjoutCreditSousCompte()
    }
}
package main

import (
	"bytes"
	"encoding/json"
	"io/ioutil"
	"log"
	"net/http"
)

type SubaccountData struct {
	APIKey         string `json:"apiKey"`
	Credit         string `json:"credit"`
	TokenSubaccount string `json:"tokenSubaccount"`
}

func main() {
	apiKey := "YOUR_API_KEY"
	credit := "100"
	tokenSubaccount := "identifiant du sous-compte"

	// Create POST request data
	data := SubaccountData{
		APIKey:         apiKey,
		Credit:         credit,
		TokenSubaccount: tokenSubaccount,
	}
	jsonData, _ := json.Marshal(data)

	// Create POST request
	req, err := http.NewRequest("POST", "https://api.smspartner.fr/v1/subaccount/credit/add", bytes.NewBuffer(jsonData))
	if err != nil {
		log.Fatalf("Error creating request: %v", err)
	}
	req.Header.Set("Content-Type", "application/json")

	// Send the request
	client := &http.Client{}
	resp, err := client.Do(req)
	if err != nil {
		log.Fatalf("Error sending request: %v", err)
	}
	defer resp.Body.Close()

	// Read the response
	body, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		log.Fatalf("Error reading response: %v", err)
	}

	// Print the response body
	log.Printf("Response body: %s", string(body))
}
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;

class Program
{
    private static readonly HttpClient client = new HttpClient();

    static async Task Main(string[] args)
    {
        var data = new
        {
            apiKey = "YOUR API KEY",
            credit = "100",
            tokenSubaccount = "Subaccount ID"
        };

        string jsonString = JsonConvert.SerializeObject(data);

        var content = new StringContent(jsonString, Encoding.UTF8, "application/json");

        HttpResponseMessage response = await client.PostAsync("https://api.smspartner.fr/v1/subaccount/credit/add", content);

        if (response.IsSuccessStatusCode)
        {
            string result = await response.Content.ReadAsStringAsync();
            Console.WriteLine(result);
        }
        else
        {
            Console.WriteLine("POST request failed with status code: " + response.StatusCode);
        }
    }
}

Response

{
    "success": true,
    "code": 200,
    "credit": 2869.2,
    "subaccountCredit": 61.8,
    "currency": "EUR"
}
<?xml version="1.0" encoding="UTF-8"?>
<result>
    <entry>true</entry>
    <entry>200</entry>
    <entry>2859.2</entry>
    <entry>71.8</entry>
    <entry>
        <![CDATA[EUR]]>
    </entry>
</result>

Errors

{
    "success": false,
    "code": 10,
    "message": "Clé API incorrecte"
}
<?xml version="1.0" encoding="UTF-8"?>
<result>
    <entry>false</entry>
    <entry>10</entry>
    <entry>
        <![CDATA[Clé API incorrecte]]>
    </entry>
</result>

Error Codes

Response Code
Message

1

API key is required

2

Credit amount is required

3

Sub-account identifier is required

4

You are not authorized

5

Credit to assign must be greater than 0

6

Your balance must be greater than 0

7

Sub-account does not exist

8

Insufficient credit

10

Invalid API key

200

Everything went well!

Remove Credits

From your main account, you can remove credits from your sub-accounts. The credits will be added back to your main account.

URL

POST https://api.smspartner.fr/v1/subaccount/credit/remove

Required Parameters

Name
Value

apiKey

credit

Amount of credit in Euros to remove from the sub-account

tokenSubaccount

Sub-account identifier

Requests

<?php
        // Prepare data for POST request
        $fields = array(
            'apiKey'=> 'YOUR API KEY',
            'credit'=> '100',
            'tokenSubaccount'=>'identifiant du sous-compte'
            );
 
 
        $curl = curl_init();
        curl_setopt($curl, CURLOPT_URL,'https://api.smspartner.fr/v1/subaccount/credit/remove');
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($curl, CURLOPT_TIMEOUT, 10);
        curl_setopt($curl, CURLOPT_POST, 1);
        curl_setopt($curl, CURLOPT_POSTFIELDS,json_encode($fields));
 
        $result = curl_exec($curl);
        curl_close($curl);
 
        // Process your response here
        echo $result;
?>
Imports System.IO
Imports System.Net
 
Module Module1
 
  Sub Main()
 
    Dim base_url As String = "http://api.smspartner.fr/v1/"
    Dim apiKey As String = "VOTRE_APIKEY"
 
    #send sms
    url = base_url & "subaccount/credit/remove"
    #note : utiliser une librairie JSON en production, par exemple :
    #https//www.nuget.org/packages/Newtonsoft.Json/
    Dim parameters As String = String.Format(
        "{{""apiKey"":""{0}"",""credit"":""{1}"",""tokenSubaccount"":""{2}""}}",
        apiKey,
        50,
        "identifiant du sous-compte")
    Console.Write(parameters)
    apiRequest("POST", url, parameters)
 
  End Sub
 
  Function apiRequest(method As String, url As String, parameters As String) As String
 
    Dim request As HttpWebRequest
    request = WebRequest.Create(url)
    request.Method = method
    request.Timeout = 10000   # timeout in ms
    request.ContentType = "application/json; charset=utf-8"
    request.ContentLength = 0
 
    #set POST data
    If Not String.IsNullOrEmpty(parameters) Then
      request.ContentLength = parameters.Length
      Using reqStream As StreamWriter = New StreamWriter(request.GetRequestStream())
        reqStream.Write(parameters)
      End Using
    End If
 
    #get response
    Dim returnValue As String = Nothing
    Using response As HttpWebResponse = request.GetResponse()
      If response.StatusCode = HttpStatusCode.OK Then
        Using resStream = response.GetResponseStream()
          If resStream IsNot Nothing Then
            Using reader As New StreamReader(resStream)
              returnValue = reader.ReadToEnd()
            End Using
          End If
        End Using
      End If
    End Using
    apiRequest = returnValue
 
  End Function
 
End Module
# std
import logging
import json
from collections import OrderedDict
 
# 3p
import requests
 
API_KEY = "MY API KEY"
URL = "https://api.smspartner.fr/v1"
 
class SMSPartner():
    def add_credit(self,creditToAdd,tokenSubaccount):
 
		data = OrderedDict([
			("apiKey", API_KEY),
			("credit",creditToAdd),
			("tokenSubaccount",tokenSubaccount)
 
		])
 
		url = URL + "/subaccount/credit/remove"
		r = requests.post(url, data=json.dumps(data), verify=False)
 
		r_json = r.json()
		if r_json.get("success") == True:
			print(r_json)
			status = True
		else:
			print(r_json)
			status = False
		return status
curl -H  "Content-Type: application/json" -X POST -d '{"apiKey":"xxxxx","credit":"10","tokenSubaccount":"identifiant du sous-compte"}' https://api.smspartner.fr/v1/subaccount/credit/remove
const https = require('https');

// permet d'ajouter des crédits à un sous-compte
//Depuis votre compte, il vous est possible d’ajouter des crédits sur vos sous comptes. Les crédits seront débités de votre compte principal.
let data = JSON.stringify({
  apiKey: 'YOUR API KEY',
  credit: '100',
  tokenSubaccount: 'identifiant du sous-compte'
});

let options = {
  hostname: 'api.smspartner.fr',
  path: '/v1/subaccount/credit/remove',
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Content-Length': data.length
  }
};

let req = https.request(options, (res) => {
  let data = '';

  res.on('data', (chunk) => {
    data += chunk;
  });

  res.on('end', () => {
    console.log(JSON.parse(data));
  });

}).on("error", (err) => {
  console.log("Error: " + err.message);
});

req.write(data);
req.end();
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;

public class AjouterRetirerDesCredits {
    public static void main(String[] args) {
        try {
            // Prepare data for POST request
            String apiKey = "YOUR API KEY";
            int credit = 100;
            String tokenSubaccount = "identifiant du sous-compte";

            // Create JSON payload
            String jsonPayload = "{\"apiKey\": \"" + apiKey + "\", \"credit\": " + credit + ", \"tokenSubaccount\": \"" + tokenSubaccount + "\"}";

            // Create POST request
            URL url = new URL("https://api.smspartner.fr/v1/subaccount/credit/remove");
            HttpURLConnection connection = (HttpURLConnection) url.openConnection();
            connection.setRequestMethod("POST");
            connection.setRequestProperty("Content-Type", "application/json");
            connection.setDoOutput(true);

            // Send POST request
            OutputStream outputStream = connection.getOutputStream();
            outputStream.write(jsonPayload.getBytes());
            outputStream.flush();
            outputStream.close();

            // Get response
            int responseCode = connection.getResponseCode();
            BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
            StringBuilder response = new StringBuilder();
            String line;
            while ((line = reader.readLine()) != null) {
                response.append(line);
            }
            reader.close();

            // Process your response here
            System.out.println(response.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
import SwiftUI

struct AjoutCreditSousCompte: View {
    @State private var result: String = "Loading..."

    var body: some View {
        VStack {
            Text("Ajout Credit Sous Compte")
                .font(.title)
                .padding()

            Text(result)
                .font(.system(size: 20))
                .padding()
        }
        .onAppear(perform: ajoutCreditSousCompte)
    }

    func ajoutCreditSousCompte() {
        let apiKey = "YOUR_API_KEY"
        let credit = "100"
        let tokenSubaccount = "identifiant du sous-compte"

        let urlString = "https://api.smspartner.fr/v1/subaccount/credit/remove"
        let url = URL(string: urlString)!

        var request = URLRequest(url: url)
        request.httpMethod = "POST"
        request.addValue("application/json", forHTTPHeaderField: "Content-Type")

        let parameters: [String: Any] = [
            "apiKey": apiKey,
            "credit": credit,
            "tokenSubaccount": tokenSubaccount
        ]

        request.httpBody = try? JSONSerialization.data(withJSONObject: parameters)

        let task = URLSession.shared.dataTask(with: request) { (data, response, error) in
            if let error = error {
                print("Error: \(error)")
            } else if let data = data {
                let resultString = String(data: data, encoding: .utf8)
                DispatchQueue.main.async {
                    self.result = resultString ?? "Error"
                }
            }
        }

        task.resume()
    }
}

struct AjoutCreditSousCompte_Previews: PreviewProvider {
    static var previews: some View {
        AjoutCreditSousCompte()
    }
}
package main

import (
	"bytes"
	"encoding/json"
	"io/ioutil"
	"log"
	"net/http"
)

type SubaccountData struct {
	APIKey         string `json:"apiKey"`
	Credit         string `json:"credit"`
	TokenSubaccount string `json:"tokenSubaccount"`
}

func main() {
	apiKey := "YOUR_API_KEY"
	credit := "100"
	tokenSubaccount := "identifiant du sous-compte"

	// Create POST request data
	data := SubaccountData{
		APIKey:         apiKey,
		Credit:         credit,
		TokenSubaccount: tokenSubaccount,
	}
	jsonData, _ := json.Marshal(data)

	// Create POST request
	req, err := http.NewRequest("POST", "https://api.smspartner.fr/v1/subaccount/credit/remove", bytes.NewBuffer(jsonData))
	if err != nil {
		log.Fatalf("Error creating request: %v", err)
	}
	req.Header.Set("Content-Type", "application/json")

	// Send the request
	client := &http.Client{}
	resp, err := client.Do(req)
	if err != nil {
		log.Fatalf("Error sending request: %v", err)
	}
	defer resp.Body.Close()

	// Read the response
	body, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		log.Fatalf("Error reading response: %v", err)
	}

	// Print the response body
	log.Printf("Response body: %s", string(body))
}
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;

class Program
{
    private static readonly HttpClient client = new HttpClient();

    static async Task Main(string[] args)
    {
        var data = new
        {
            apiKey = "YOUR API KEY",
            credit = "100",
            tokenSubaccount = "Subaccount ID"
        };

        string jsonString = JsonConvert.SerializeObject(data);

        var content = new StringContent(jsonString, Encoding.UTF8, "application/json");

        HttpResponseMessage response = await client.PostAsync("https://api.smspartner.fr/v1/subaccount/credit/remove", content);

        if (response.IsSuccessStatusCode)
        {
            string result = await response.Content.ReadAsStringAsync();
            Console.WriteLine(result);
        }
        else
        {
            Console.WriteLine("POST request failed with status code: " + response.StatusCode);
        }
    }
}

Response

{
    "success": true,
    "code": 200,
    "credit": 2869.2,
    "subaccountCredit": 61.8,
    "currency": "EUR"
}
<?xml version="1.0" encoding="UTF-8"?>
<result>
    <entry>true</entry>
    <entry>200</entry>
    <entry>2859.2</entry>
    <entry>71.8</entry>
    <entry>
        <![CDATA[EUR]]>
    </entry>
</result

Errors

{
    "success": false,
    "code": 10,
    "message": "Invalid API key"
}
<?xml version="1.0" encoding="UTF-8"?>
<result>
    <entry>false</entry>
    <entry>10</entry>
    <entry>
        <![CDATA[Invalid API key]]>
    </entry>
</result>

Error Codes

Response Code
Message

1

API key is required

2

Credit amount is required

3

Sub-account identifier is required

4

You are not authorized

5

Credit to assign must be greater than 0

6

Your balance must be greater than 0

7

Sub-account does not exist

8

Insufficient credit

10

Invalid API key

200

Everything went well!

PreviousSub-account ListNextManage Call Forwarding

Last updated 1 month ago

Your API key
Your API key