Link Replacements API
- Table of Contents
- Overview
- Attributes
- Link Replacement Uniqueness
- Link Replacement Priority
- Get a List of Link Replacements
- Get Details on a Single Link Replacement
- Create a Link Replacement
- Update a Link Replacement
- Delete a Link Replacement
Overview
Link Replacements provide a mechanism for modifying the destination and/or expiration of a SimpleMH link after the email has been sent.
Link Replacements are performed at the time of the click. The purpose of this is to allow links with mistakes in them to be fixed, or to shut down links that are being abused.
Attributes
The following are the configurable attributes defined for Link Replacements.
link_replacement
hash /required
|
Link Replacement Uniqueness
Link Replacements must be unique for their matching criteria – this means that only one Link Replacement
can exist for any given combination of mailclass
, instanceid
, match_type
, match_string
, and linkid
.
Link Replacement Priority
Link Replacements are evaluated from most-specific to least-specific mailclass
and instanceid
settings:
-
mailclass
andinstanceid
is set -
mailclass
is set,instanceid
is not set -
mailclass
andinstanceid
are not set
Additionally, if multiple matches are found, ties will be broken by specificity of the match_type
:
linkid
exact
regexp
all
If there’s still a tie after the above evaluations, the earliest created (lowest id
)
Link Replacement will be used.
Get a List of Link Replacements
GET /ga/api/v3/eng/link_replacements
Parameters
The following parameters are valid for the above endpoint.
page
integer /optional |
The page number from which to retrieve. Page numbering starts at |
page_token
string /optional |
The |
mailclass
string /optional |
Filter the results to just a single Mail Class (case-insensitive). If this parameter is specified and blank, this will filter the results to link replacements that do not specify a Mail Class. |
instanceid
string /optional |
Filter the results to just a single InstanceID (case-insensitive). If this parameter is specified and blank, this will filter the results to link replacements that do not specify an InstanceID. Can only be specified if |
Examples:
GET /ga/api/v3/eng/link_replacements?page={page}
GET /ga/api/v3/eng/link_replacements?page_token={page_token}
GET /ga/api/v3/eng/link_replacements?mailclass={mailclass}
GET /ga/api/v3/eng/link_replacements?mailclass={mailclass}&instance={instance}
Response
The response will contain a list of Link Replacements in the following format.
link_replacements
array of hashes
|
|||||||||||
pagination
hash
|
Example
GET /ga/api/v3/eng/link_replacements
HTTP/1.1 200 OK
{
"success": true,
"data": {
"link_replacements": [
{
"id": 1,
"match_type": "all",
"mailclass": {
"id": 1,
"name": "foo"
},
"instanceid": "1234",
"match_string": null,
"linkid": null,
"replacement_string": "http://foo.com",
"replacement_includes_capture_refs": null,
"expiration_time": null,
"notes": null
},
{
"id": 2,
"match_type": "all",
"mailclass": null,
"instanceid": null,
"match_string": null,
"linkid": null,
"replacement_string": "http://foo.com",
"replacement_includes_capture_refs": null,
"expiration_time": null,
"notes": null
},
{
"id": 3,
"match_type": "all",
"mailclass": {
"id": 1,
"name": "foo"
},
"instanceid": "12345",
"match_string": null,
"linkid": null,
"replacement_string": "http://foo.com",
"replacement_includes_capture_refs": null,
"expiration_time": null,
"notes": null
}
],
"pagination": {
"page": 0,
"per_page": 100,
"num_pages": 1,
"num_records": 3,
"next_page_token": null
}
},
"error_code": null,
"error_messages": null
}
Get Details on a Single Link Replacement
GET /ga/api/v3/eng/link_replacements/{id}
Response
The response will contain details on the requested record:
link_replacement
hash |
The attributes for this hash are defined in the Attributes section of this document. |
Example
GET /ga/api/v3/eng/link_replacements/16
HTTP/1.1 200 OK
{
"success": true,
"data": {
"link_replacement": {
"id": 16,
"match_type": "all",
"mailclass": {
"id": 6,
"name": "foo"
},
"instanceid": "1234",
"match_string": null,
"linkid": null,
"replacement_string": "http://foo.com",
"replacement_includes_capture_refs": null,
"expiration_time": null,
"notes": null
}
},
"error_code": null,
"error_messages": null
}
Create a Link Replacement
POST /ga/api/v3/eng/link_replacements
Payload
link_replacement
hash /required |
The content of this hash is described in the Attributes section of this page. The data may contain a mixture of required and optional fields. Do not specify read-only fields. |
Response
The response will include a link_replacement
key containing the full Link Replacement
record as defined in the Attributes.
Example
POST /ga/api/v3/eng/link_replacements
{
"link_replacement": {
"match_type": "regexp",
"mailclass": {
"id": 9
},
"instanceid": "1234",
"match_string": ".*",
"linkid": "5000",
"replacement_string": "https://example.com",
"replacement_includes_capture_refs": true,
"expiration_time": "2023-12-15T13:14:03Z"
}
}
HTTP/1.1 200 OK
{
"success": true,
"data": {
"link_replacement": {
"id": 28,
"match_type": "regexp",
"mailclass": {
"id": 9,
"name": "foo"
},
"instanceid": "1234",
"match_string": ".*",
"linkid": "5000",
"replacement_string": "https://example.com",
"replacement_includes_capture_refs": true,
"expiration_time": "2023-12-15 13:14:03",
"notes": null
}
},
"error_code": null,
"error_messages": null
}
Update a Link Replacement
PUT /ga/api/v3/eng/link_replacements/{id}
Payload
link_replacement
hash /required |
The content of this hash is described in the Attributes section of this page. The data may contain a mixture of required and optional fields. Do not specify read-only fields. |
Response
The response will include a link_replacement
key containing the full Link Replacement
record as defined in the Attributes.
Example
PUT /ga/api/v3/eng/link_replacements/22
{
"link_replacement": {
"linkid": "foo bar",
"notes": "hey there\nthis is a note\n"
}
}
HTTP/1.1 200 OK
{
"success": true,
"data": {
"link_replacement": {
"id": 22,
"match_type": "all",
"mailclass": {
"id": 8,
"name": "foo"
},
"instanceid": "1234",
"match_string": null,
"linkid": "foo bar",
"replacement_string": "http://foo.com",
"replacement_includes_capture_refs": null,
"expiration_time": null,
"notes": "hey there\nthis is a note"
}
},
"error_code": null,
"error_messages": null
}
Delete a Link Replacement
DELETE /ga/api/v3/eng/link_replacements/{id}
Response
The response is a standard success or error response.
Example
DELETE /ga/api/v3/eng/link_replacements/19
HTTP/1.1 200 OK
{
"success": true,
"data": {
},
"error_code": null,
"error_messages": null
}