Convert

Join an array into one text

POST/v1/convert/array/to/string

View as Markdown

Joins the items, or one property of an array of objects, with a separator. A different last separator gives wording such as 'a, b and c'. Prefix and suffix wrap every item, and empty items are skipped by default. An empty array gives an empty text, not an error.

Request body

Name Type Required Description
items array of any yes The array
key string no For an array of objects, the property to join (a dotted path such as owner.email reaches into nested objects)
separator string no Text between items (default ", ")
last_separator string no Text before the last item instead of the separator, for example ' and ' gives a, b and c
prefix string no Text added before every item (default "")
suffix string no Text added after every item (default "")
skip_empty boolean no Leave out null, empty and blank items (default true)

Example request

A request body that works, as JSON.

{
  "items": [
    "workflow",
    "automation",
    "excel"
  ],
  "prefix": "#",
  "last_separator": " and "
}

Code samples

Replace YOUR_TOKEN with your access token.

curl

curl -X POST 'https://api.skillfulsardine.com/v1/convert/array/to/string' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "items": [
    "workflow",
    "automation",
    "excel"
  ],
  "prefix": "#",
  "last_separator": " and "
}'

PowerShell

$body = @'
{
  "items": [
    "workflow",
    "automation",
    "excel"
  ],
  "prefix": "#",
  "last_separator": " and "
}
'@
$response = Invoke-RestMethod -Method Post -Uri 'https://api.skillfulsardine.com/v1/convert/array/to/string' `
  -Headers @{ Authorization = 'Bearer YOUR_TOKEN' } `
  -ContentType 'application/json; charset=utf-8' `
  -Body ([System.Text.Encoding]::UTF8.GetBytes($body))
$response | ConvertTo-Json -Depth 10

Python

import requests

payload = {
    "items": [
        "workflow",
        "automation",
        "excel",
    ],
    "prefix": "#",
    "last_separator": " and ",
}

response = requests.post(
    "https://api.skillfulsardine.com/v1/convert/array/to/string",
    headers={"Authorization": "Bearer YOUR_TOKEN"},
    json=payload,
    timeout=30,
)
print(response.json())

JavaScript

const response = await fetch("https://api.skillfulsardine.com/v1/convert/array/to/string", {
  method: "POST",
  headers: {
    "Authorization": "Bearer YOUR_TOKEN",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
  "items": [
    "workflow",
    "automation",
    "excel"
  ],
  "prefix": "#",
  "last_separator": " and "
}),
});
const result = await response.json();
console.log(result);

Node

// Node 18 or later. Save as call.mjs and run: API_TOKEN=... node call.mjs
const token = process.env.API_TOKEN;

const response = await fetch("https://api.skillfulsardine.com/v1/convert/array/to/string", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${token}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
  "items": [
    "workflow",
    "automation",
    "excel"
  ],
  "prefix": "#",
  "last_separator": " and "
}),
});
const result = await response.json();
console.log(result);

Rust

// Cargo.toml: reqwest = { version = "0.12", features = ["blocking", "json"] }, serde_json = "1"
fn main() -> Result<(), Box<dyn std::error::Error>> {
    let body: serde_json::Value = serde_json::from_str(r##"{
  "items": [
    "workflow",
    "automation",
    "excel"
  ],
  "prefix": "#",
  "last_separator": " and "
}"##)?;
    let response = reqwest::blocking::Client::new()
        .post("https://api.skillfulsardine.com/v1/convert/array/to/string")
        .bearer_auth("YOUR_TOKEN")
        .json(&body)
        .send()?;
    println!("{}", response.text()?);
    Ok(())
}

Swift

import Foundation

var request = URLRequest(url: URL(string: "https://api.skillfulsardine.com/v1/convert/array/to/string")!)
request.httpMethod = "POST"
request.setValue("Bearer YOUR_TOKEN", forHTTPHeaderField: "Authorization")
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
request.httpBody = Data(#"""
{
  "items": [
    "workflow",
    "automation",
    "excel"
  ],
  "prefix": "#",
  "last_separator": " and "
}
"""#.utf8)

let (data, _) = try await URLSession.shared.data(for: request)
print(String(decoding: data, as: UTF8.self))

Response

The fields inside data of a successful response.

Name Type Required Description
text string yes The items joined, empty when there is nothing to join
count integer yes Number of items that went into the text

Example response

A real answer from the operation, as JSON. The fields in the table above are inside data.

{
  "data": {
    "text": "#workflow, #automation and #excel",
    "count": 3
  },
  "errors": null,
  "meta": {
    "request_id": "c7a68f83-553c-4a59-a2b8-c6b57c8ac143",
    "timestamp": "2026-10-27T07:19:42.015214Z",
    "version": "2026-03-26"
  },
  "pagination": null
}

Responses

Status When it happens
200 Successful Response
400 The body respects the operation schema, but the use case rejected it. Each problem is one ApiError entry
413 The request is larger than the request size limit of the API allows
422 The body does not respect the operation schema. Each problem is one ApiError entry with the code validation_error
500 Something failed inside the server and was not an input problem. The same envelope, errors may be empty