Example: Creating a policy using the graph endpoints

As described in Streamlined account and submission creation, you can create an entire submission by using two endpoints from the Graph API:

  • POST /graph/v1/accounts

  • POST /graph/v1/submissions

These endpoints can be run independently or included in a composite request to create an end-to-end submission. The response is an output graph that can be read by calling applications that need to process an entire submission at once.

Overview

The examples presented here demonstrate the process of creating a complete account and submission using the Graph API.

  • The first example creates an account. The account includes an initial account holder, primary location, and an additional locaction.
  • The next example creates a submission. The submission includes several pieces of information that would require calls to multiple child endpoints if you were to use the Job API to complete a similar task. This example shows how to create the entire submission in one step.
  • The final example creates a composite request that strings together the commands from the preceding examples to create an account and a submission, and quote the submission. It then shows binding and issuing the submission.

Create an account for the submission

Every submission must be associated with an account. All the account information for a submission can be gathered in one step with the following command:

POST /graph/v1/accounts

The required request fields are the same for posting a Graph API account as for posting to an Account API account (see Creating an account).

In addition to the required and other top-level account fields, you can include fields that are considered children of the account, such as contacts and locations. The following request creates an account and includes an additional location.

Request

{
  "data": {
    "attributes": {
      "producerCodes": [{
        "id": "pc:6"
      }],
      "initialAccountHolder": {
        "contactSubtype": "Person",
        "firstName": "August",
        "lastName": "Joseph",
        "primaryAddress": {
          "addressLine1": "2850 S. Delaware St.",
          "city": "San Mateo",
          "postalCode": "94403",
          "state": {
            "code": "CA"
          }
        }
      },
      "initialPrimaryLocation": {
        "addressLine1": "2850 S. Delaware St.",
        "city": "San Mateo",
        "postalCode": "94403",
        "state": {
          "code": "CA"
        }
      },
      "locations": [{
        "active": true,
        "addressLine1": "1234 Main St.",
        "city": "San Diego",
        "country": "US",
        "postalCode": "91911",
        "state": {
          "code": "CA"
        }
      }]
    }
  }
}

Response

{
  "data": {
    "attributes": {
      "accountHolder": {
        "displayName": "August Joseph",
        "id": "pc:120"
      },
      "accountNumber": "12345678",
      "accountStatus": {
        "code": "Pending",
        "name": "Pending"
      },
      "contacts": [{
        "accountContactRoles": [{
          "code": "AccountHolder",
          "name": "AccountHolder"
        }],
      ...
      "locations": [{
          "active": true,
          "addressLine1": "2850 S. Delaware St.",
          "city": "San Mateo",
          "country": "US",
          "displayName": "1: 2850 S. Delaware St., San Mateo, CA",
          "id": "pc:SpsZPtDDb4H8uswOqP_fh",
          "locationNum": 1,
          "nonSpecific": false,
          "postalCode": "94403",
          "state": {
            "code": "CA",
            "name": "California"
          }
        },
        {
          "active": true,
          "addressLine1": "1234 Main St.",
          "city": "San Diego",
          "country": "US",
          "displayName": "2: 1234 Main St., San Diego, CA",
          "id": "pc:SjqOMu8aIXl4bbeUHfwzt",
          "locationNum": 2,
          "nonSpecific": false,
          "postalCode": "91911",
          "state": {
            "code": "CA",
            "name": "California"
          }
        }
      ],
...
      "primaryLocation": {
        "displayName": "1: 2850 S. Delaware St., San Mateo, CA",
        "id": "pc:2345",
     ...
    }
  }
}

Create the job graph for a submission

All the job information for a submission can be gathered in one step with the following command:

POST /graph/v1/submissions

The request for this POST command can contain all information included in the job hierarchy, such as answers, locations, and all the submission details.

The following request performs these actions:

  1. Creates a submission from an existing account (id: pc:120).
  2. Answers the question “Is the applicant currently insured” with “No - New Driver” (newdriver).
  3. Creates a new contact. Assigns a refid to the contact.
  4. Includes a new PersonalAutoLine with the following (only one LOB can be specified, multiple lines in a request are not supported):
    1. Answers two questions (q1 and q3) on the line
    2. Adds liability coverage
    3. Adds a vehicle
    4. Adds a driver to the vehicle. Driver is the contact with the refid defined earlier.
Note:

The POST /graph/v1/submissions endpoint does not quote the submission. To quote the submission you need to call POST /job/v1/jobs/quote.

Request

{
  "data": {
    "attributes": {
      "account": {
        "id": "pc:120"
      },
      "baseState": {
        "code": "CA"
      },
      "jobEffectiveDate": "2023-09-01",
      "producerCode": {
        "id": "pc:6"
      },
      "product": {
        "id": "PersonalAuto"
      },
      "answers": {
        "PACurrentlyInsured": {
          "choiceValue": {
            "code": "newdriver"
          }
        }
      },
      "contacts": [{
        "contactSubtype": "Person",
        "firstName": "Samantha",
        "lastName": "Stewart",
        "primaryAddress": {
          "addressLine1": "2850 S. Delaware St.",
          "city": "San Mateo",
          "postalCode": "94403",
          "state": {
            "code": "CA"
          }
        },
        "refid": "testUser"
      }],
      "lines": {
        "PersonalAutoLine": {
          "answers": {
            "q1": {
              "booleanValue": false
            },
            "q3": {
              "choiceValue": {
                "code": "no"
              }
            }
          },
          "coverages": {
            "PALiabilityCov": {
              "terms": {
                "PALiability": {
                  "choiceValue": {
                    "code": "100/200/50"
                  }
                }
              }
            }
          },
          "numAddInsured": 1,
          "vehicles": [{
            "annualMileage": 10000,
            "bodyType": {
              "code": "convertible"
            },
            "color": "Yellow",
            "commutingMiles": 50,
            "costNew": {
              "amount": "25000.00",
              "currency": "usd"
            },
            "coverages": {
              "PACollisionCov": {
                "terms": {
                  "PACollDeductible": {
                    "choiceValue": {
                      "code": "1000"
                    }
                  }
                }
              },
              "PARentalCov": {
                "pattern": {
                  "id": "PARentalCov"
                },
                "terms": {
                  "PARental": {
                    "choiceValue": {
                      "code": "30/15"
                    }
                  }
                }
              }
            },
            "drivers": [{
              "percentageDriven": 100,
              "policyDriver": {
                "refid": "testUser"
              }
            }],
            "make": "NewMake",
            "model": "NewModel",
            "modelYear": 2015,
            "modifiers": {
              "PAAntiLockBrakes": {
                "booleanModifier": true,
                "eligible": false,
                "valueFinal": false
              }
            },
            "vin": "1234567890"
          }]
        }
      }
    }
  }
}

Response

{
  "data": {
    "attributes": {
      "account": {
        "displayName": "12345678",
        "id": "pc:120",
        "type": "Account",
        "uri": "..."
      },
      "answers": {
        ...
        "PACurrentlyInsured": {
          "choiceValue": {
            "code": "newdriver",
            "name": "No - New Driver"
          },
          "displayValue": "No - New Driver",
          "question": {
            "displayName": "Is the applicant currently insured?",
            "id": "PACurrentlyInsured"
          },
          "questionType": {
            "code": "Choice",
            "name": "Choice"
          }
        },
        ...
      },
      "contacts": [{
          "accountContact": {
            "displayName": "August Joseph",
            "id": "pc:110",
            "type": "AccountContact",
            "uri": "..."
          },
          ...
      "jobStatus": {
        "code": "Draft",
        "name": "Draft"
      },
      "jobType": {
        "code": "Submission",
        "name": "Submission"
      },
      "lines": {
        "PersonalAutoLine": {
          "answers": {
            "q1": {
              "booleanValue": false,
              "displayValue": "false",
              "question": {
                "displayName": "Have you been convicted for a moving traffic violation within the past 3 years?",
                "id": "q1"
              },
              "questionType": {
                "code": "Boolean",
                "name": "Boolean"
              }
            },
            "q2": {
              "question": {
                "displayName": "Has any policy or coverage been declined, canceled, or non-renewed during the prior 3 years?",
                "id": "q2"
              },
              "questionType": {
                "code": "Boolean",
                "name": "Boolean"
              }
            },
            "q3": {
              "choiceValue": {
                "code": "no",
                "name": "No - previous policy did not renew"
              },
              "displayValue": "No - previous policy did not renew",
              "question": {
                "displayName": "Has your license ever been canceled, suspended or revoked?",
                "id": "q3"
              },
              "questionType": {
                "code": "Choice",
                "name": "Choice"
              }
            },
          ...
          "coverages": {
            "PALiabilityCov": {
              "clauseType": "coverage",
              "id": "PALiabilityCov",
              "pattern": {
                "displayName": "Liability - Bodily Injury and Property Damage",
                "id": "PALiabilityCov"
              },
              "selected": true,
              "terms": {
                "PALiability": {
                  "choiceValue": {
                    "code": "100/200/50",
                    "name": "100/200/50"
                  },
                  "covTermType": "choice",
                  "displayValue": "100/200/50",
                  "pattern": {
                    "displayName": "Auto Liability Package",
                    "id": "PALiability"
                  }
                }
              }
            },
            "PALimitedMexicoCov": {
              "clauseType": "coverage",
              "id": "PALimitedMexicoCov",
              "pattern": {
                "displayName": "Mexico Coverage - Limited",
                "id": "PALimitedMexicoCov"
              },
              "selected": true,
              "terms": {}
            },
            "PAMedPayCov": {
              "clauseType": "coverage",
              "id": "PAMedPayCov",
              "pattern": {
                "displayName": "Medical Payments",
                "id": "PAMedPayCov"
              },
              "selected": true,
              "terms": {
                "PAMedLimit": {
                  "choiceValue": {
                    "code": "5000",
                    "name": "5,000"
                  },
                  "covTermType": "choice",
                  "displayValue": "5,000",
                  "pattern": {
                    "displayName": "Medical Limit",
                    "id": "PAMedLimit"
                  }
                }
              }
            },
            "PAUMBICov": {
              "clauseType": "coverage",
              "id": "PAUMBICov",
              "pattern": {
                "displayName": "Uninsured Motorist - Bodily Injury",
                "id": "PAUMBICov"
              },
              "selected": true,
              "terms": {
                "PAUMBI": {
                  "choiceValue": {
                    "code": "25/50",
                    "name": "25/50"
                  },
                  "covTermType": "choice",
                  "displayValue": "25/50",
                  "pattern": {
                    "displayName": "Uninsured Motorist - BI Limits",
                    "id": "PAUMBI"
                  }
                }
              }
            },
            "PAUMPDCov": {
              "clauseType": "coverage",
              "id": "PAUMPDCov",
              "pattern": {
                "displayName": "Uninsured Motorist - Property Damage",
                "id": "PAUMPDCov"
              },
              "selected": true,
              "terms": {
                "PAUMPDLimit": {
                  "choiceValue": {
                    "code": "3500",
                    "name": "3,500"
                  },
                  "covTermType": "choice",
                  "displayValue": "3,500",
                  "pattern": {
                    "displayName": "Uninsured Motorist - Property Damage Limit",
                    "id": "PAUMPDLimit"
                  }
                }
              }
            }
          },
          ...
          "patternCode": "PersonalAutoLine",
          "vehicles": [{
            "annualMileage": 10000,
            "bodyType": {
              "code": "convertible",
              "name": "Convertible"
            },
            "color": "Yellow",
            "commutingMiles": 50,
            "costNew": {
              "amount": "25000.00",
              "currency": "usd"
            },
            "coverableJurisdiction": {
              "code": "CA",
              "name": "California"
            },
            "coverages": {
              "PACollisionCov": {
                "clauseType": "coverage",
                "id": "PACollisionCov",
                "pattern": {
                  "displayName": "Collision",
                  "id": "PACollisionCov"
                },
                "selected": true,
                "terms": {
                  "PACollDeductible": {
                    "choiceValue": {
                      "code": "1000",
                      "name": "1,000"
                    },
                    "covTermType": "choice",
                    "displayValue": "1,000",
                    "pattern": {
                      "displayName": "Collision Deductible",
                      "id": "PACollDeductible"
                    }
                  }
                }
              },
              "PAComprehensiveCov": {
                "clauseType": "coverage",
                "id": "PAComprehensiveCov",
                "pattern": {
                  "displayName": "Comprehensive",
                  "id": "PAComprehensiveCov"
                },
                "selected": true,
                "terms": {
                  "PACompDeductible": {
                    "choiceValue": {
                      "code": "500",
                      "name": "500"
                    },
                    "covTermType": "choice",
                    "displayValue": "500",
                    "pattern": {
                      "displayName": "Comprehensive Deductible",
                      "id": "PACompDeductible"
                    }
                  }
                }
              },
              "PARentalCov": {
                "clauseType": "coverage",
                "id": "PARentalCov",
                "pattern": {
                  "displayName": "Rental Reimbursement",
                  "id": "PARentalCov"
                },
                "selected": true,
                "terms": {
                  "PARental": {
                    "choiceValue": {
                      "code": "30/15",
                      "name": "30 days x 15/day"
                    },
                    "covTermType": "choice",
                    "displayValue": "30 days x 15/day",
                    "pattern": {
                      "displayName": "Rental Package",
                      "id": "PARental"
                    }
                  }
                }
              }
            },
            "drivers": [{
              "id": "301",
              "percentageDriven": 100,
              "policyDriver": {
                "displayName": "Samantha Stewart",
                "id": "pc:145",
                "type": "PolicyContact",
                "uri": "..."
              }
            }],
            "garageLocation": {
              "displayName": "1: 2850 S. Delaware St., San Mateo, CA",
              "id": "501",
              "type": "PolicyLocation",
              "uri": "..."
            },
            "id": "301",
            "leaseOrRent": false,
            "make": "NewMake",
            "model": "NewModel",
            "modelYear": 2015,
            ...
      "locations": [{
        "accountLocation": {
          "displayName": "1: 2850 S. Delaware St., San Mateo, CA",
          "id": "pc:Sro4vpAp3iD5oMrD7SqwF",
          "type": "AccountLocation",
          "uri": "..."
        },
        "addressLine1": "2850 S. Delaware St.",
        "city": "San Mateo",
        "country": "US",
        "displayName": "1: 2850 S. Delaware St., San Mateo, CA",
        "id": "501",
        "locationNum": 1,
        "postalCode": "94403",
        "primary": true,
        "state": {
          "code": "CA",
          "name": "California"
        },
        "territoryCodes": {
          "PersonalAutoLine": {
            "code": "31"
          }
        }
      }],
      ...
      "producerCode": {
        "displayName": "100-000001",
        "id": "pc:6"
      },
      "producerCodeOfService": {
        "displayName": "100-000001",
        "id": "pc:6"
      },
      "product": {
        "displayName": "Personal Auto",
        "id": "PersonalAuto"
      },
      "quoteType": {
        "code": "Full",
        "name": "Full Application"
      },
      "termType": {
        "code": "HalfYear",
        "name": "6 months"
      },
       ...
      }
    }
  }
}

Create a submission composite request

You can use a composite request to create a single request that will gather all account and submission information. The following example runs the POST commands on accounts and submissions to generate the account and submission graphs.

Command

POST /composite/v1/composite

This example combines the examples in the preceding sections into one composite request. It also performs the additional step of quoting the submission, then binds and issues the submission.

The composite request performs the following steps:

  1. Calls POST /graph/v1/accounts to create an account
  2. Saves the account ID from the account that was created to be passed into the body of the next sub-request.
  3. Calls POST /graph/v1/submissions to create a submission
  4. Saves the job ID from the submission to be passed into the body of the next sub-request
  5. Calls POST /job/v1/jobs/{jobId}/quote to quote the job

When the composite request completes, you can then call POST /job/v1/jobs/{jobId}/bind-and-issue to bind and issue the job.

Request

{
  "requests": [{
      "method": "post",
      "uri": "/graph/v1/accounts",
      "body": {
        "data": {
          "attributes": {
            "producerCodes": [{
              "id": "pc:6"
            }],
            "initialAccountHolder": {
              "contactSubtype": "Person",
              "firstName": "August",
              "lastName": "Joseph",
              "primaryAddress": {
                "addressLine1": "2850 S. Delaware St.",
                "city": "San Mateo",
                "postalCode": "94403",
                "state": {
                  "code": "CA"
                }
              }
            },
            "initialPrimaryLocation": {
              "addressLine1": "2850 S. Delaware St.",
              "city": "San Mateo",
              "postalCode": "94403",
              "state": {
                "code": "CA"
              }
            },
            "locations": [{
              "active": true,
              "addressLine1": "1234 Main St.",
              "city": "San Diego",
              "country": "US",
              "postalCode": "91911",
              "state": {
                "code": "CA"
              }
            }]
          }
        }
      },
      "vars": [{
        "name": "accountId",
        "path": "$.data.attributes.id"
      }]
    },
    {
      "method": "post",
      "uri": "/graph/v1/submissions",
      "body": {
        "data": {
          "attributes": {
            "account": {
              "id": "${accountId}"
            },
            "baseState": {
              "code": "CA"
            },
            "jobEffectiveDate": "2023-09-01",
            "producerCode": {
              "id": "pc:6"
            },
            "product": {
              "id": "PersonalAuto"
            },
            "answers": {
              "PACurrentlyInsured": {
                "choiceValue": {
                  "code": "newdriver"
                }
              }
            },
            "contacts": [{
              "contactSubtype": "Person",
              "firstName": "Samantha",
              "lastName": "Stewart",
              "primaryAddress": {
                "addressLine1": "2850 S. Delaware St.",
                "city": "San Mateo",
                "postalCode": "94403",
                "state": {
                  "code": "CA"
                }
              },
              "refid": "testUser"
            }],
            "lines": {
              "PersonalAutoLine": {
                "answers": {
                  "q1": {
                    "booleanValue": false
                  },
                  "q3": {
                    "choiceValue": {
                      "code": "no"
                    }
                  }
                },
                "coverages": {
                  "PALiabilityCov": {
                    "terms": {
                      "PALiability": {
                        "choiceValue": {
                          "code": "100/200/50"
                        }
                      }
                    }
                  }
                },
                "numAddInsured": 1,
                "vehicles": [{
                  "annualMileage": 10000,
                  "bodyType": {
                    "code": "convertible"
                  },
                  "color": "Yellow",
                  "commutingMiles": 50,
                  "costNew": {
                    "amount": "25000.00",
                    "currency": "usd"
                  },
                  "coverages": {
                    "PACollisionCov": {
                      "terms": {
                        "PACollDeductible": {
                          "choiceValue": {
                            "code": "1000"
                          }
                        }
                      }
                    },
                    "PARentalCov": {
                      "pattern": {
                        "id": "PARentalCov"
                      },
                      "terms": {
                        "PARental": {
                          "choiceValue": {
                            "code": "30/15"
                          }
                        }
                      }
                    }
                  },
                  "drivers": [{
                    "percentageDriven": 100,
                    "policyDriver": {
                      "refid": "testUser"
                    }
                  }],
                  "make": "NewMake",
                  "model": "NewModel",
                  "modelYear": 2015,
                  "modifiers": {
                    "PAAntiLockBrakes": {
                      "booleanModifier": true,
                      "eligible": false,
                      "valueFinal": false
                    }
                  },
                  "vin": "1234567890"
                }]
              }
            }
          }
        }
      },
      "vars": [{
        "name": "jobId",
        "path": "$.data.attributes.id"
      }]
    },
    {
      "method": "post",
      "uri": "/job/v1/jobs/${jobId}/quote"
    }
  ]
}

The response from the composite request contains sub-responses with the results of each of the calls within the request.

Important: The response shown here is only a very small sample of the graph that will actually be returned. Shown here is just enough to demonstrate that responses have been returned from the three separate POST commands, and that the submisson has successfully moved through creation of an account and a submission to a quoted state.

Response

{
  "responses": [{
      "body": {
        "data": {
          "attributes": {
            "accountHolder": {
              "displayName": "August Joseph",
              "id": "pc:120"
            },
            "accountNumber": "12345678",
            "accountStatus": {
              "code": "Pending",
              "name": "Pending"
            },
         ...
      "status": 201
    },
    {
      "body": {
        "data": {
          "attributes": {
            "account": {
              "displayName": "12345678",
              "id": "pc:130",
              "type": "Account",
              "uri": "..."
            },
            ...
            "id": "pc:150",
            "jobEffectiveDate": "2023-09-01T07:01:00.000Z",
            "jobNumber": "0000123456",
            "jobStatus": {
              "code": "Draft",
              "name": "Draft"
            },
            "jobType": {
              "code": "Submission",
              "name": "Submission"
            },
            "lines": {
              "PersonalAutoLine": {
                "answers": {
                  "q1": {
                    "booleanValue": false,
                    "displayValue": "false",
      ...
      "status": 201
    },
    {
      "body": {
        "data": {
          "attributes": {
            "account": {
              "displayName": "12345678",
              "id": "pc:120",
              "type": "Account",
              "uri": "..."
            },
            "id": "pc:150",
            "jobEffectiveDate": "2023-09-01T07:01:00.000Z",
            "jobNumber": "0000123456",
            "jobStatus": {
              "code": "Quoted",
              "name": "Quoted"
            },
            "jobType": {
              "code": "Submission",
              "name": "Submission"
            },
      ...
      "status": 200
    }
  ]
}

At this point you can perform the additional step of binding and issuing the submission:

Command

POST /job/v1/jobs/pc:150/bind-and-issue

Response

{
  "data": {
    "attributes": {
      "account": {
        "displayName": "12345678",
        "id": "pc:120",
        ...
      "id": "pc:150",
      "jobEffectiveDate": "2023-09-01T07:01:00.000Z",
      "jobNumber": "0000123456",
      "jobStatus": {
        "code": "Bound",
        "name": "Bound"
      },
      "jobType": {
        "code": "Submission",
        "name": "Submission"
      },
      ...
    }
  }
}