SDK reference · Node SDK
prov.account.importTextConsents
prov.account.importTextConsents in Node SDK. Slice 2: import a CSV of phones that agreed to your texts (mode company, Pro and up): the columns phone, method, obtained_at and, optionally, evidence_url; up to 50,000 rows and 5 MB.
Signature
prov.account.importTextConsents(file: string | Uint8Array | Blob, opts?: { fileName?: string }): Promise<TextConsentImport>Parameters
filestring | Uint8Array | BlobRequiredopts{ fileName?: string }
Request fields
file_namestringquery- The file's name, shown on the import (a form post's own file name is used otherwise).
Returns
Promise<TextConsentImport> The same file was sent within a day; this is the earlier import, and nothing new was written.
HTTP operation
POST /v1/account/text_consent_imports: Import consents to text from a CSV
Errors
- authentication_required
- parameter_invalid
- plan_required
- text_consent_mode_mismatch
- rate_limit_exceeded
- text_consents_unavailable
Example
import { readFile } from "node:fs/promises";
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/account/text_consent_imports?file_name=consents.csv`, {
method: "POST",
headers: { Authorization: `Bearer ${process.env.PROVENANCE_KEY}`, "Content-Type": "text/csv" },
body: await readFile("consents.csv"),
})).json();import os
import httpx
api = os.environ["PROVENANCE_API"]
with open("consents.csv", "rb") as f:
data = httpx.post(
f"{api}/v1/account/text_consent_imports",
params={"file_name": "consents.csv"},
headers={"Authorization": f"Bearer {os.environ['PROVENANCE_KEY']}", "Content-Type": "text/csv"},
content=f.read(),
).json()