Skip to main content
POST
/
api
/
v2
/
patients
/
cURL
curl --request POST \
  --url https://app.spotdx.com/api/v2/patients/ \
  --header 'Authorization: <api-key>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "first_name": "Alice",
  "last_name": "Smith",
  "email": "alice123@gmail.com",
  "sex": "F",
  "date_of_birth": "2023-12-25",
  "phone": "1234567890"
}
'
import requests

url = "https://app.spotdx.com/api/v2/patients/"

payload = {
    "first_name": "Alice",
    "last_name": "Smith",
    "email": "alice123@gmail.com",
    "sex": "F",
    "date_of_birth": "2023-12-25",
    "phone": "1234567890"
}
headers = {
    "Authorization": "<api-key>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
  method: 'POST',
  headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
  body: JSON.stringify({
    first_name: 'Alice',
    last_name: 'Smith',
    email: 'alice123@gmail.com',
    sex: 'F',
    date_of_birth: '2023-12-25',
    phone: '1234567890'
  })
};

fetch('https://app.spotdx.com/api/v2/patients/', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://app.spotdx.com/api/v2/patients/",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => json_encode([
    'first_name' => 'Alice',
    'last_name' => 'Smith',
    'email' => 'alice123@gmail.com',
    'sex' => 'F',
    'date_of_birth' => '2023-12-25',
    'phone' => '1234567890'
  ]),
  CURLOPT_HTTPHEADER => [
    "Authorization: <api-key>",
    "Content-Type: application/json"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://app.spotdx.com/api/v2/patients/"

	payload := strings.NewReader("{\n  \"first_name\": \"Alice\",\n  \"last_name\": \"Smith\",\n  \"email\": \"alice123@gmail.com\",\n  \"sex\": \"F\",\n  \"date_of_birth\": \"2023-12-25\",\n  \"phone\": \"1234567890\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "<api-key>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://app.spotdx.com/api/v2/patients/")
  .header("Authorization", "<api-key>")
  .header("Content-Type", "application/json")
  .body("{\n  \"first_name\": \"Alice\",\n  \"last_name\": \"Smith\",\n  \"email\": \"alice123@gmail.com\",\n  \"sex\": \"F\",\n  \"date_of_birth\": \"2023-12-25\",\n  \"phone\": \"1234567890\"\n}")
  .asString();
require 'uri'
require 'net/http'

url = URI("https://app.spotdx.com/api/v2/patients/")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"first_name\": \"Alice\",\n  \"last_name\": \"Smith\",\n  \"email\": \"alice123@gmail.com\",\n  \"sex\": \"F\",\n  \"date_of_birth\": \"2023-12-25\",\n  \"phone\": \"1234567890\"\n}"

response = http.request(request)
puts response.read_body
{
  "first_name": "Alice",
  "last_name": "Smith",
  "email": "alice123@gmail.com",
  "sex": "F",
  "date_of_birth": "2023-12-25",
  "phone": "1234567890"
}
{
  "error": {
    "status": 400,
    "type": "bad_request",
    "detail": "The first_name field is required"
  }
}
{
  "error": {
    "status": 404,
    "type": "forbidden",
    "detail": "Kit id SPOTZZZZZZ not found"
  }
}

Authorizations

Authorization
string
header
required

Token-based authentication with required prefix "Token"

Body

first_name
string
required

The first name of the patient.

Example:

"Alice"

last_name
string
required

The last name of the patient to be created.

Example:

"Smith"

email
string<email>
required

The email of the patient to be created.

Example:

"alice123@gmail.com"

sex
enum<string>
required

The biological sex of the patient to be created.

Available options:
M,
F
Example:

"F"

date_of_birth
string<date>
required

The date of birth of the patient to be created.

phone
string

Optional phone number of the patient.

Example:

"1234567890"

Response

first_name
string
required

The first name of the patient.

Example:

"Alice"

last_name
string
required

The last name of the patient to be created.

Example:

"Smith"

email
string<email>
required

The email of the patient to be created.

Example:

"alice123@gmail.com"

sex
enum<string>
required

The biological sex of the patient to be created.

Available options:
M,
F
Example:

"F"

date_of_birth
string<date>
required

The date of birth of the patient to be created.

phone
string

Optional phone number of the patient.

Example:

"1234567890"