'use strict'; import React, {Component} from 'react'; import {withTranslation} from '../lib/i18n'; import {Trans} from 'react-i18next'; import { requiresAuthenticatedUser, Title, withPageHelpers } from '../lib/page' import { withAsyncErrorHandler, withErrorHandling } from '../lib/error-handling'; import axios from '../lib/axios'; import {Button} from '../lib/bootstrap-components'; import {getUrl} from "../lib/urls"; import {withComponentMixins} from "../lib/decorator-helpers"; import styles from "./styles.scss" @withComponentMixins([ withTranslation, withErrorHandling, withPageHelpers, requiresAuthenticatedUser ]) export default class API extends Component { constructor(props) { super(props); this.state = { accessToken: null }; } @withAsyncErrorHandler async loadAccessToken() { const response = await axios.get(getUrl('rest/access-token')); this.setState({ accessToken: response.data }); } componentDidMount() { // noinspection JSIgnoredPromiseFromCall this.loadAccessToken(); } async resetAccessToken() { const response = await axios.post(getUrl('rest/access-token-reset')); this.setState({ accessToken: response.data }); } render() { const t = this.props.t; const accessToken = this.state.accessToken || 'ACCESS_TOKEN'; let accessTokenMsg; if (this.state.accessToken) { accessTokenMsg =
{t('personalAccessToken') + ': '}{accessToken}
; } else { accessTokenMsg =
{t('accessTokenNotYetGenerated')}
; } return (
{t('api')}
{accessTokenMsg}

{t('notesAboutTheApi')}

  • API response is a JSON structure with error and data properties. If the response error has a value set then the request failed.
  • You need to define proper Content-Type when making a request. You can either use application/x-www-form-urlencoded for normal form data or application/json for a JSON payload. Using multipart/form-data is not supported.
POST /api/subscribe/:listId – {t('addSubscription')}

{t('thisApiCallEitherInsertsANewSubscription')}

POST /api/subscribe/:listId – {t('addSubscription')}

{t('thisApiCallEitherInsertsANewSubscription')}

GET {t('arguments')}

POST {t('arguments')}

{t('additionalPostArguments')}:

{t('example')}

curl -XPOST '{getUrl(`api/subscribe/B16uVTdW?access_token=${accessToken}`)}' \
--data 'EMAIL=test@example.com&MERGE_CHECKBOX=yes&REQUIRE_CONFIRMATION=yes'

POST /api/unsubscribe/:listId – {t('removeSubscription')}

{t('thisApiCallMarksASubscriptionAs')}

GET {t('arguments')}

POST {t('arguments')}

{t('example')}

curl -XPOST '{getUrl(`api/unsubscribe/B16uVTdW?access_token=${accessToken}`)}' \
--data 'EMAIL=test@example.com'

POST /api/delete/:listId – {t('deleteSubscription')}

{t('thisApiCallDeletesASubscription')}

GET {t('arguments')}

POST {t('arguments')}

{t('example')}

curl -XPOST '{getUrl(`api/delete/B16uVTdW?access_token=${accessToken}`)}' \
--data 'EMAIL=test@example.com'

POST /api/field/:listId – {t('addNewCustomField')}

{t('thisApiCallCreatesANewCustomFieldForA')}

GET {t('arguments')}

POST {t('arguments')}

{t('example')}

curl -XPOST '{getUrl(`api/field/B16uVTdW?access_token=${accessToken}`)}' \
--data 'NAME=Birthday&TYPE=birthday-us&VISIBLE=yes'

GET /api/blacklist/get – {t('getListOfBlacklistedEmails')}

{t('thisApiCallGetListOfBlacklistedEmails')}

GET {t('arguments')}

{t('example')}

curl -XGET '{getUrl(`api/blacklist/get?access_token=${accessToken}&limit=10&start=10&search=gmail`)}' 

POST /api/blacklist/add – {t('addEmailToBlacklist')}

{t('thisApiCallEitherAddEmailsToBlacklist')}

GET {t('arguments')}

POST {t('arguments')}

{t('example')}

curl -XPOST '{getUrl(`api/blacklist/add?access_token={accessToken}`)}' \
--data 'EMAIL=test@example.com&'

POST /api/blacklist/delete – {t('deleteEmailFromBlacklist')}

{t('thisApiCallEitherDeleteEmailsFrom')}

GET {t('arguments')}

POST {t('arguments')}

{t('example')}

curl -XPOST '{getUrl(`api/blacklist/delete?access_token=${accessToken}`)}' \
--data 'EMAIL=test@example.com&'

GET /api/lists/:email – {t('getTheListsAUserHasSubscribedTo')}

{t('retrieveTheListsThatTheUserWithEmailHas')}

GET {t('arguments')}

{t('example')}

curl -XGET '{getUrl(`api/lists/test@example.com?access_token=${accessToken}`)}'

GET /api/rss/fetch/:campaignCid – {t('Trigger fetch of a campaign')}

{t('Forces the RSS feed check to immediately check the campaign with the given CID (in :campaignCid). It works only for RSS campaigns.')}

GET {t('arguments')}

{t('example')}

curl -XGET '{getUrl(`api/rss/fetch/5OOnZKrp0?access_token=${accessToken}`)}'

POST /api/templates/:templateId/send – {t('sendTransactionalEmail')}

{t('sendSingleEmailByTemplateId')}

GET {t('arguments')}

POST {t('arguments')}

{t('example')}

curl -XPOST '{getUrl(`api/templates/1/send?access_token={accessToken}`)}' \
--data 'EMAIL=test@example.com&SUBJECT=Test&VARIABLES[FOO]=bar&VARIABLES[TEST]=example'
); } }