addUnplannedVisit
Requires permission visits:visit:execute.
Adds an unplanned visit to a customer on the signed-in rep's route. The customer must be in the rep's book, or their team's or the organization's according to their visibility. Requires permission to run visits.
Errors: a failed call returns a GraphQL errors entry, not a field on the result, and data may be null or partial. Read the entry's extensions.code and message; every shape and code is in the Error reference.
Example:
- GraphQL
- cURL
mutation AddUnplannedVisit($partnerId: ID!) {
addUnplannedVisit(partnerId: $partnerId) {
id
partnerName
status
createdAt
completedAt
hasUnreadMessage
checkIns {
id
createdAt
checkInAt
checkOutAt
checkOutLatitude
checkOutLongitude
}
}
}
curl -X POST "https://<api-host>/graphql" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
--data @- <<'EOF'
{
"query": "mutation AddUnplannedVisit($partnerId: ID!) {\n addUnplannedVisit(partnerId: $partnerId) {\n id\n partnerName\n status\n createdAt\n completedAt\n hasUnreadMessage\n checkIns {\n id\n createdAt\n checkInAt\n checkOutAt\n checkOutLatitude\n checkOutLongitude\n }\n }\n}",
"variables": {
"partnerId": "id"
}
}
EOF
Variables:
{
"partnerId": "id"
}
Response:
{
"data": {
"addUnplannedVisit": {
"id": "id",
"partnerName": "string",
"status": "CANCELLED",
"createdAt": "2025-01-15T00:00:00Z",
"completedAt": "2025-01-15T00:00:00Z",
"hasUnreadMessage": true,
"checkIns": [
{
"id": "id",
"createdAt": "2025-01-15T00:00:00Z",
"checkInAt": "2025-01-15T00:00:00Z",
"checkOutAt": "2025-01-15T00:00:00Z",
"checkOutLatitude": 0,
"checkOutLongitude": 0
}
]
}
}
}
addUnplannedVisit(
date: DateTime
onlyIfNotScheduled: Boolean
partnerId: ID!
): Visit!
Arguments
addUnplannedVisit.date ● DateTime scalar
The day of the visit. Omit it for today.
addUnplannedVisit.onlyIfNotScheduled ● Boolean scalar
True to return the rep's existing stop for this customer and day instead of adding a second one. Omit it to allow a second visit on the same day.
addUnplannedVisit.partnerId ● ID! non-null scalar
The ID of the customer to visit.
Type
Visit object
A planned or unplanned visit to a customer.