Common Models

The following is an example of a Labor Tag which is applicable to Events but not to Locations. (To search for a Location searchable with a Labor Code, you’d create a child of this Code that is applicable.) This Tag’s parent has parentCodeId which, in this example, is a Code called Constituencies.

{
  "codeId": 20515,
  "parentCodeId": 20513,
  "name": "Labor",
  "description": "This is a description of Labor.",
  "codeType": "Tag",
  "dateCreated": "2015-04-05T12:59:00Z",
  "dateModified": "2015-05-05T16:00:00Z",
  "supportedEntities": [
    {
      "name": "Events",
      "isSearchable": true,
      "isApplicable": true
    },
    {
      "name": "Locations",
      "isSearchable": true,
      "isApplicable": false
    }
  ]
}

The following Source Code is used to keep track of people and contributions that came from digital ad campaigns:

{
  "codeId": 20615,
  "parentCodeId": null,
  "name": "Digital ads",
  "description": "Used to mark people and contributions retrieved because of digital ad campaigns",
  "codeType": "SourceCode",
  "dateCreated": "2017-10-05T12:59:00Z",
  "dateModified": "2017-10-08T12:00:00Z",
  "supportedEntities": null
}

The following Source Code has all supported metadata set (not all metadata is available in all contexts):

{
  "codeId": 1098919,
  "parentCodeId": null,
  "name": "CodesApiTest-CreateSourceCode 22-06-02 055623",
  "description": "Some description",
  "codePath": "CodesApiTest-CreateSourceCode 22-06-02 055623",
  "createdByName": "An API User",
  "dateCreated": "2022-06-02T12:56:00Z",
  "supportedEntities": [
    {
      "name": "Contacts",
      "isSearchable": true,
      "isApplicable": true
    },
    {
      "name": "Events",
      "isSearchable": true,
      "isApplicable": true
    },
    {
      "name": "Contributions",
      "isSearchable": true,
      "isApplicable": true
    },
    {
      "name": "RecurringContributions",
      "isSearchable": true,
      "isApplicable": true
    },
    {
      "name": "Pledges",
      "isSearchable": true,
      "isApplicable": true
    },
    {
      "name": "OnlineForms",
      "isSearchable": true,
      "isApplicable": true
    },
    {
      "name": "ContactsDisbursements",
      "isSearchable": true,
      "isApplicable": true
    },
    {
      "name": "ActionPlans",
      "isSearchable": true,
      "isApplicable": true
    },
    {
      "name": "DirectResponsePlanSubSegments",
      "isSearchable": true,
      "isApplicable": true
    },
    {
      "name": "PlannedGift",
      "isSearchable": true,
      "isApplicable": true
    }
  ],
  "codeType": "SourceCode",
  "campaign": {
    "campaignId": 2541,
    "name": "ATC Campaign",
    "campaignType": {
      "campaignTypeId": 211,
      "name": "Auto"
    },
    "campaignDisplayName": "Auto: ATC Campaign",
    "status": "Active",
    "contents": null
  },
  "contactType": {
    "contactTypeId": 82,
    "channelTypeName": "Mail",
    "name": "Direct Mail"
  },
  "dateModified": "2022-06-02T12:56:00Z",
  "generalLedgerFund": {
    "generalLedgerFundId": 69,
    "name": "API GL Fund Inactive",
    "description": "Intentionally Inactive API General Ledger Fund for Source Code testing",
    "isActive": false
  },
  "costCenter": {
    "costCenterId": 47,
    "name": "API Cost Center for Tests",
    "description": "Cost Center for Functional API Tests (Source Codes)",
    "isActive": true
  },
  "revenueStream": {
    "revenueStreamId": 179,
    "name": "API Revenue Stream for Source Codes",
    "type": {
      "revenueStreamTypeID": 449,
      "name": "API Functional Tests for Source Codes"
    },
    "status": "Active"
  },
  "mailMergeTemplate": {
    "mailMergeTemplateId": 337,
    "name": "API Mail Merge Template for Tests"
  },
  "isSourceCodeApplicable": true
}

The following list of Codes is formatted for batch operations:

{
  "codes": [
    {
      "parentCodeID": "1019966",
      "name": "Labor",
      "description": "The tag for describing Labor",
      "supportedEntities": [
        {
          "name": "Contacts",
          "isSearchable": true,
          "isApplicable": true
        },
        {
          "name": "ActivistCodes",
          "isSearchable": true,
          "isApplicable": true
        }
      ],
      "codeType": "Tag"
    },
    {
      "name": "Volunteers",
      "description": "The tab for describing all of our Volunteers",
      "supportedEntities": null,
      "codeType": "Tag"
    }
  ]
}

Code

Each Code has the following properties:

PropertyTypeDescription
codeIdintRead-only; Unique identifier for a Code in this context
parentCodeIdintOptional; a unique identifier for this Code’s parent
namestringA name for this Code, no longer than 50 characters and is not guaranteed to be unique. In addition to the standard text input validation rules, valid characters vary by codeType. Tags may not contain forward or back slashes or asterisks. Source Codes must contain only alphanumeric, _, and - characters.
descriptionstringA description for this Code, no longer than 200 characters and may be null.
codeTypestringIndicates whether a Code is a Tag or Source Code. Valid values are Tag and SourceCode. Default is SourceCode.
dateCreateddatetimeRead-only; The date and time this Code was created
supportedEntitiesarrayOptional; An array of zero or more Supported Entity objects that enumerate the searchability and applicability rules of this Code. These applicability rules can vary by entity for Tags but are consistent across all entities for Source Codes.

SourceCode-Specific Properties

When the codeType is SourceCode, the following properties are also available.

PropertyTypeDescription
campaignobjectThe Campaign associated with this Source Code
contactTypeobjectThe Contact Type associated with this Source Code
directResponsePlanobjectThe Direct Response Plan associated with this Source Code
generalLedgerFundobjectThe General Ledger Fund associated with this Source Code
costCenterobjectThe Cost Center associated with this Source Code
revenueStreamobjectThe Revenue Stream associated with this Source Code
mailMergeTemplateobjectThe Mail Merge Template associated with this Source Code
isSourceCodeApplicableboolIndicates whether the Source Code can be applied to entities or is just for searching.

Supported Entity

Each Supported Entity has the following properties:

PropertyTypeDescription
namestringRequired; A name of a valid Supported Entity type available in this context
isSearchableboolRequired; Indicates that this Code is searchable. This should always be true.
isApplicableboolOptional; Indicates that this Code can be applied to entities of type name.

Codes

Each list of Codes has the following properties:

PropertyTypeDescription
codesarrayRequired; An array of zero or more Code objects for batch operations.