completeVisit
Requires permission visits:visit:execute.
Completes a visit with its outcome and, when no order came of it, the reason. A visit that is already completed, cancelled or skipped is refused when completed online; an offline replay of an already completed visit returns it unchanged and does not overwrite its outcome. 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 CompleteVisit($outcome: VisitOutcome!, $visitId: ID!) {
completeVisit(outcome: $outcome, visitId: $visitId) {
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 CompleteVisit($outcome: VisitOutcome!, $visitId: ID!) {\n completeVisit(outcome: $outcome, visitId: $visitId) {\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": {
"outcome": "NO_ORDER",
"visitId": "id"
}
}
EOF
Variables:
{
"outcome": "NO_ORDER",
"visitId": "id"
}
Response:
{
"data": {
"completeVisit": {
"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
}
]
}
}
}
completeVisit(
clientCompletedAt: DateTime
noOrderReason: String
outcome: VisitOutcome!
visitId: ID!
): Visit!
Arguments
completeVisit.clientCompletedAt ● DateTime scalar
When the rep completed the visit, for an offline replay.
completeVisit.noOrderReason ● String scalar
Why no order was taken. Optional.
completeVisit.outcome ● VisitOutcome! non-null enum
The result of the visit.
completeVisit.visitId ● ID! non-null scalar
The ID of the visit.
Type
Visit object
A planned or unplanned visit to a customer.