{
  "info": {
    "name": "Engagifii CRM API",
    "description": "Comprehensive API collection for the Engagifii CRM platform with authentication, people management, organizations, committees, and advocacy features.",
    "version": "1.0.0",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "auth": {
    "type": "bearer",
    "bearer": [
      {
        "key": "token",
        "value": "{{access_token}}",
        "type": "string"
      }
    ]
  },
  "variable": [
    {
      "key": "base_url",
      "value": "https://builtin-crm.azurewebsites.net/api/v1",
      "type": "string"
    },
    {
      "key": "token_url",
      "value": "https://builtin-crm.azurewebsites.net/oauth/token",
      "type": "string"
    },
    {
      "key": "client_id",
      "value": "your-client-id",
      "type": "string"
    },
    {
      "key": "client_secret",
      "value": "your-client-secret",
      "type": "string"
    },
    {
      "key": "tenant_code",
      "value": "your-tenant-code",
      "type": "string"
    },
    {
      "key": "access_token",
      "value": "",
      "type": "string"
    }
  ],
  "item": [
    {
      "name": "Authentication",
      "item": [
        {
          "name": "Get Access Token",
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "if (pm.response.code === 200) {",
                  "    const response = pm.response.json();",
                  "    pm.collectionVariables.set('access_token', response.access_token);",
                  "    console.log('Access token updated:', response.access_token.substring(0, 20) + '...');",
                  "} else {",
                  "    console.log('Token request failed:', pm.response.text());",
                  "}"
                ]
              }
            }
          ],
          "request": {
            "auth": {
              "type": "noauth"
            },
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/x-www-form-urlencoded"
              }
            ],
            "body": {
              "mode": "urlencoded",
              "urlencoded": [
                {
                  "key": "grant_type",
                  "value": "client_credentials",
                  "type": "text"
                },
                {
                  "key": "client_id",
                  "value": "{{client_id}}",
                  "type": "text"
                },
                {
                  "key": "client_secret",
                  "value": "{{client_secret}}",
                  "type": "text"
                }
              ]
            },
            "url": {
              "raw": "{{token_url}}",
              "host": ["{{token_url}}"]
            },
            "description": "Obtain an OAuth2 access token using client credentials flow"
          }
        }
      ],
      "description": "Authentication endpoints for obtaining access tokens"
    },
    {
      "name": "People Management",
      "item": [
        {
          "name": "List People with Pagination",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "tenant-code",
                "value": "{{tenant_code}}"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"pageIndex\": 0,\n  \"pageSize\": 50,\n  \"sortField\": \"lastName\",\n  \"sortDirection\": \"asc\",\n  \"filter\": {\n    \"isActive\": true\n  }\n}"
            },
            "url": {
              "raw": "{{base_url}}/people/PeoplePagingList",
              "host": ["{{base_url}}"],
              "path": ["people", "PeoplePagingList"]
            },
            "description": "Retrieve a paginated list of people with filtering options"
          }
        },
        {
          "name": "Get Person by ID",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "tenant-code",
                "value": "{{tenant_code}}"
              }
            ],
            "url": {
              "raw": "{{base_url}}/people/{{person_id}}",
              "host": ["{{base_url}}"],
              "path": ["people", "{{person_id}}"]
            },
            "description": "Retrieve detailed information about a specific person"
          }
        },
        {
          "name": "Create Person",
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "if (pm.response.code === 201) {",
                  "    const response = pm.response.json();",
                  "    pm.collectionVariables.set('person_id', response.id);",
                  "    console.log('Person created with ID:', response.id);",
                  "}"
                ]
              }
            }
          ],
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "tenant-code",
                "value": "{{tenant_code}}"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"firstName\": \"John\",\n  \"lastName\": \"Doe\",\n  \"email\": \"john.doe@example.com\",\n  \"phone\": \"+1-555-123-4567\",\n  \"title\": \"Software Engineer\",\n  \"addresses\": [\n    {\n      \"type\": \"Primary\",\n      \"street\": \"123 Main Street\",\n      \"city\": \"New York\",\n      \"state\": \"NY\",\n      \"zipCode\": \"10001\",\n      \"country\": \"USA\"\n    }\n  ]\n}"
            },
            "url": {
              "raw": "{{base_url}}/people/CreatePersonInline/{{organization_id}}",
              "host": ["{{base_url}}"],
              "path": ["people", "CreatePersonInline", "{{organization_id}}"]
            },
            "description": "Create a new person associated with an organization"
          }
        },
        {
          "name": "Update Person",
          "request": {
            "method": "PUT",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "tenant-code",
                "value": "{{tenant_code}}"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"firstName\": \"John\",\n  \"lastName\": \"Doe\",\n  \"email\": \"john.doe.updated@example.com\",\n  \"phone\": \"+1-555-123-4567\",\n  \"title\": \"Senior Software Engineer\"\n}"
            },
            "url": {
              "raw": "{{base_url}}/people/UpdatePersonHeader/{{person_id}}",
              "host": ["{{base_url}}"],
              "path": ["people", "UpdatePersonHeader", "{{person_id}}"]
            },
            "description": "Update an existing person's information"
          }
        },
        {
          "name": "Search People",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "tenant-code",
                "value": "{{tenant_code}}"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"pageIndex\": 0,\n  \"pageSize\": 20,\n  \"filter\": {\n    \"isActive\": true\n  }\n}"
            },
            "url": {
              "raw": "{{base_url}}/people/SearchPeopleList/john",
              "host": ["{{base_url}}"],
              "path": ["people", "SearchPeopleList", "john"]
            },
            "description": "Search for people using text query"
          }
        },
        {
          "name": "Add Tags to People",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "tenant-code",
                "value": "{{tenant_code}}"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"peopleIds\": [\n    \"{{person_id}}\"\n  ],\n  \"tagIds\": [\n    \"tag-vip\",\n    \"tag-board-member\"\n  ],\n  \"action\": \"add\"\n}"
            },
            "url": {
              "raw": "{{base_url}}/people/AddPeoplesTags",
              "host": ["{{base_url}}"],
              "path": ["people", "AddPeoplesTags"]
            },
            "description": "Add tags to multiple people for categorization"
          }
        }
      ],
      "description": "Person and member management operations"
    },
    {
      "name": "Organization Management",
      "item": [
        {
          "name": "List Organizations",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "tenant-code",
                "value": "{{tenant_code}}"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"pageIndex\": 0,\n  \"pageSize\": 50,\n  \"sortField\": \"name\",\n  \"sortDirection\": \"asc\",\n  \"filter\": {\n    \"isActive\": true\n  }\n}"
            },
            "url": {
              "raw": "{{base_url}}/organization/OrganizationPagingList",
              "host": ["{{base_url}}"],
              "path": ["organization", "OrganizationPagingList"]
            },
            "description": "Retrieve a paginated list of organizations"
          }
        },
        {
          "name": "Get Organization by ID",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "tenant-code",
                "value": "{{tenant_code}}"
              }
            ],
            "url": {
              "raw": "{{base_url}}/organization/{{organization_id}}",
              "host": ["{{base_url}}"],
              "path": ["organization", "{{organization_id}}"]
            },
            "description": "Retrieve detailed information about a specific organization"
          }
        },
        {
          "name": "Create Organization",
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "if (pm.response.code === 201) {",
                  "    const response = pm.response.json();",
                  "    pm.collectionVariables.set('organization_id', response.id);",
                  "    console.log('Organization created with ID:', response.id);",
                  "}"
                ]
              }
            }
          ],
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "tenant-code",
                "value": "{{tenant_code}}"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"name\": \"Acme Corporation\",\n  \"type\": \"Company\",\n  \"description\": \"Leading provider of innovative solutions\",\n  \"website\": \"https://acme.com\",\n  \"email\": \"info@acme.com\",\n  \"phone\": \"+1-555-000-1234\",\n  \"addresses\": [\n    {\n      \"type\": \"Headquarters\",\n      \"street\": \"100 Corporate Boulevard\",\n      \"city\": \"San Francisco\",\n      \"state\": \"CA\",\n      \"zipCode\": \"94105\",\n      \"country\": \"USA\"\n    }\n  ]\n}"
            },
            "url": {
              "raw": "{{base_url}}/organization",
              "host": ["{{base_url}}"],
              "path": ["organization"]
            },
            "description": "Create a new organization"
          }
        },
        {
          "name": "Get Organization Members",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "tenant-code",
                "value": "{{tenant_code}}"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"pageIndex\": 0,\n  \"pageSize\": 50,\n  \"filter\": {\n    \"isActive\": true\n  }\n}"
            },
            "url": {
              "raw": "{{base_url}}/organization/{{organization_id}}/GetAllPeople",
              "host": ["{{base_url}}"],
              "path": ["organization", "{{organization_id}}", "GetAllPeople"]
            },
            "description": "Get all people associated with an organization"
          }
        },
        {
          "name": "Get Child Organizations",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "tenant-code",
                "value": "{{tenant_code}}"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"pageIndex\": 0,\n  \"pageSize\": 50\n}"
            },
            "url": {
              "raw": "{{base_url}}/organization/{{organization_id}}/ChildOrganizationsById",
              "host": ["{{base_url}}"],
              "path": ["organization", "{{organization_id}}", "ChildOrganizationsById"]
            },
            "description": "Get child organizations of a parent organization"
          }
        }
      ],
      "description": "Organization and company management operations"
    },
    {
      "name": "Committee Management",
      "item": [
        {
          "name": "List Committees",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "tenant-code",
                "value": "{{tenant_code}}"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"pageIndex\": 0,\n  \"pageSize\": 25,\n  \"sortField\": \"name\",\n  \"sortDirection\": \"asc\",\n  \"filter\": {\n    \"isActive\": true\n  }\n}"
            },
            "url": {
              "raw": "{{base_url}}/committee/CommiteePagingList",
              "host": ["{{base_url}}"],
              "path": ["committee", "CommiteePagingList"]
            },
            "description": "Retrieve a paginated list of committees"
          }
        },
        {
          "name": "Get Committee by ID",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "tenant-code",
                "value": "{{tenant_code}}"
              }
            ],
            "url": {
              "raw": "{{base_url}}/committee/get/{{committee_id}}",
              "host": ["{{base_url}}"],
              "path": ["committee", "get", "{{committee_id}}"]
            },
            "description": "Retrieve detailed information about a specific committee"
          }
        },
        {
          "name": "Create Committee",
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "if (pm.response.code === 201) {",
                  "    const response = pm.response.json();",
                  "    pm.collectionVariables.set('committee_id', response.id);",
                  "    console.log('Committee created with ID:', response.id);",
                  "}"
                ]
              }
            }
          ],
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "tenant-code",
                "value": "{{tenant_code}}"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"name\": \"Board of Directors\",\n  \"description\": \"Executive oversight and strategic direction committee\",\n  \"committeeTypeId\": \"board-type\",\n  \"organizationId\": \"{{organization_id}}\",\n  \"isActive\": true,\n  \"startDate\": \"2024-01-01T00:00:00Z\",\n  \"positions\": [\n    {\n      \"title\": \"Chairman\",\n      \"description\": \"Committee chair and primary decision maker\",\n      \"sequence\": 1\n    },\n    {\n      \"title\": \"Secretary\",\n      \"description\": \"Record keeping and meeting coordination\",\n      \"sequence\": 2\n    }\n  ]\n}"
            },
            "url": {
              "raw": "{{base_url}}/committee/createcommittee",
              "host": ["{{base_url}}"],
              "path": ["committee", "createcommittee"]
            },
            "description": "Create a new committee with positions"
          }
        },
        {
          "name": "Add Committee Member",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "tenant-code",
                "value": "{{tenant_code}}"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"committeeId\": \"{{committee_id}}\",\n  \"personId\": \"{{person_id}}\",\n  \"positionId\": \"chairman-position-id\",\n  \"startDate\": \"2024-01-01T00:00:00Z\",\n  \"isActive\": true,\n  \"notes\": \"Appointed as committee chair for 2024 term\"\n}"
            },
            "url": {
              "raw": "{{base_url}}/committee/savecommitteemember",
              "host": ["{{base_url}}"],
              "path": ["committee", "savecommitteemember"]
            },
            "description": "Add a member to a committee with a specific position"
          }
        },
        {
          "name": "Get Committee Members",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "tenant-code",
                "value": "{{tenant_code}}"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"committeeId\": \"{{committee_id}}\",\n  \"isActive\": true,\n  \"includeHistory\": false\n}"
            },
            "url": {
              "raw": "{{base_url}}/committee/GetMemberListByCommittee",
              "host": ["{{base_url}}"],
              "path": ["committee", "GetMemberListByCommittee"]
            },
            "description": "Get all members of a specific committee"
          }
        }
      ],
      "description": "Committee and governance structure management"
    },
    {
      "name": "Advocacy & Relationships",
      "item": [
        {
          "name": "Get Relationship Types",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "tenant-code",
                "value": "{{tenant_code}}"
              }
            ],
            "url": {
              "raw": "{{base_url}}/advocacy/GetRelationshipTypes",
              "host": ["{{base_url}}"],
              "path": ["advocacy", "GetRelationshipTypes"]
            },
            "description": "Get all available relationship types for advocacy connections"
          }
        },
        {
          "name": "Get People Relationships",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "tenant-code",
                "value": "{{tenant_code}}"
              }
            ],
            "url": {
              "raw": "{{base_url}}/advocacy/list/people-relationships/{{person_id}}",
              "host": ["{{base_url}}"],
              "path": ["advocacy", "list", "people-relationships", "{{person_id}}"]
            },
            "description": "Get all advocacy relationships for a specific person"
          }
        },
        {
          "name": "Save People Relationship",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "tenant-code",
                "value": "{{tenant_code}}"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"personId\": \"{{person_id}}\",\n  \"relatedOfficialId\": \"official-789\",\n  \"relationshipTypeId\": \"constituent-relationship\",\n  \"startDate\": \"2024-01-01T00:00:00Z\",\n  \"notes\": \"New constituent relationship established\",\n  \"isActive\": true\n}"
            },
            "url": {
              "raw": "{{base_url}}/advocacy/save/people-relationship",
              "host": ["{{base_url}}"],
              "path": ["advocacy", "save", "people-relationship"]
            },
            "description": "Create or update a relationship between a person and a political official"
          }
        },
        {
          "name": "Get Officials List",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "tenant-code",
                "value": "{{tenant_code}}"
              }
            ],
            "url": {
              "raw": "{{base_url}}/advocacy/officials-list-lite/{{person_id}}",
              "host": ["{{base_url}}"],
              "path": ["advocacy", "officials-list-lite", "{{person_id}}"]
            },
            "description": "Get list of political officials associated with a person"
          }
        },
        {
          "name": "Get Constituent People List",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "tenant-code",
                "value": "{{tenant_code}}"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"officialId\": \"official-789\",\n  \"pageIndex\": 0,\n  \"pageSize\": 50,\n  \"filter\": {\n    \"relationshipType\": \"Constituent\",\n    \"isActive\": true\n  }\n}"
            },
            "url": {
              "raw": "{{base_url}}/advocacy/get-constituent-people-list",
              "host": ["{{base_url}}"],
              "path": ["advocacy", "get-constituent-people-list"]
            },
            "description": "Get list of people who are constituents of a political official"
          }
        }
      ],
      "description": "Political advocacy and relationship management"
    },
    {
      "name": "Audience & Communication",
      "item": [
        {
          "name": "Get Audience Search Settings",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "tenant-code",
                "value": "{{tenant_code}}"
              }
            ],
            "url": {
              "raw": "{{base_url}}/audience/AudienceSearchSettings/people",
              "host": ["{{base_url}}"],
              "path": ["audience", "AudienceSearchSettings", "people"]
            },
            "description": "Get available search settings and filters for audience selection"
          }
        },
        {
          "name": "Search Across Modules",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "tenant-code",
                "value": "{{tenant_code}}"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"searchText\": \"john\",\n  \"modules\": [\"people\", \"organization\", \"committee\"],\n  \"pageIndex\": 0,\n  \"pageSize\": 50,\n  \"filters\": {\n    \"isActive\": true\n  }\n}"
            },
            "url": {
              "raw": "{{base_url}}/audience/ModuleSearchList",
              "host": ["{{base_url}}"],
              "path": ["audience", "ModuleSearchList"]
            },
            "description": "Search across multiple modules (people, organizations, committees)"
          }
        },
        {
          "name": "Broadcast Email",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "tenant-code",
                "value": "{{tenant_code}}"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"subject\": \"Important Update from Acme Corporation\",\n  \"body\": \"<html><body><h1>Important Update</h1><p>This is an important message for all members...</p></body></html>\",\n  \"isHtml\": true,\n  \"fromEmail\": \"noreply@acme.com\",\n  \"fromName\": \"Acme Communications\",\n  \"audienceSelection\": {\n    \"selectedPeople\": [\"{{person_id}}\"],\n    \"filters\": {\n      \"tags\": [\"newsletter-subscriber\"],\n      \"organizationType\": \"Company\"\n    }\n  },\n  \"trackOpens\": true,\n  \"trackClicks\": true\n}"
            },
            "url": {
              "raw": "{{base_url}}/audience/BroacastViaEmail",
              "host": ["{{base_url}}"],
              "path": ["audience", "BroacastViaEmail"]
            },
            "description": "Send email communication to selected audience"
          }
        }
      ],
      "description": "Audience selection and communication broadcasting"
    }
  ],
  "event": [
    {
      "listen": "prerequest",
      "script": {
        "type": "text/javascript",
        "exec": [
          "// Auto-refresh token if needed",
          "const tokenExpiry = pm.collectionVariables.get('token_expiry');",
          "const currentTime = Date.now();",
          "",
          "if (!tokenExpiry || currentTime >= tokenExpiry) {",
          "    console.log('Token expired or missing, will need to refresh');",
          "}"
        ]
      }
    },
    {
      "listen": "test",
      "script": {
        "type": "text/javascript",
        "exec": [
          "// Global test script for error handling",
          "if (pm.response.code >= 400) {",
          "    const response = pm.response.json();",
          "    console.log('API Error:', {",
          "        status: pm.response.code,",
          "        code: response.error?.code,",
          "        message: response.error?.message,",
          "        requestId: response.error?.requestId",
          "    });",
          "    ",
          "    if (pm.response.code === 401) {",
          "        console.log('Authentication failed - check access token');",
          "    }",
          "    ",
          "    if (pm.response.code === 403) {",
          "        console.log('Access forbidden - check tenant code and permissions');",
          "    }",
          "    ",
          "    if (pm.response.code === 429) {",
          "        const retryAfter = pm.response.headers.get('Retry-After');",
          "        console.log('Rate limited - retry after', retryAfter, 'seconds');",
          "    }",
          "}"
        ]
      }
    }
  ]
}