This API endpoint allows creating a train visit.

Supported Formats

json

Errors

Code Description
400 Bad Request.
500 Internal Server Error.

Examples

curl "https://app.octopi.co/api/v1/train_visits.json" -X POST \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Token token=ADD TOKEN HERE" \
--data '{
    "train_visit": {
        "visit_number": "TV001",
        "visit_type": "inbound",
        "carrier_code": "MAERSKRAIL",
        "estimated_time_of_arrival": "2026-06-01T10:00:00Z"
    }
}'
{
  "train_visit": {
    "id": 1,
    "visit_number": "TV001",
    "visit_type": "inbound",
    "carrier": { "name": "Rail" },
    "notes": null,
    "estimated_time_of_arrival": "2026-06-01T10:00:00Z",
    "actual_time_of_arrival": null,
    "operation_started_at": null,
    "operation_completed_at": null,
    "created_at": "2026-05-01T08:00:00Z",
    "updated_at": "2026-05-01T08:00:00Z"
  }
}

Params

Param name Description
train_visit
required

A hash with train visit attributes.

Validations:

  • Must be a Hash

train_visit[visit_number]
required

The train visit number.

Validations:

  • Must be a String

train_visit[visit_type]
required

The visit type. Valid values are ‘inbound’ or ‘outbound’.

Validations:

  • Must be one of: inbound, outbound.

train_visit[carrier_code]
required

The carrier code (shipping line code).

Validations:

  • Must be a String

train_visit[notes]
optional , nil allowed

Notes.

Validations:

  • Must be a String

train_visit[estimated_time_of_arrival]
optional , nil allowed

Estimated time of arrival (inbound only). Date must be in ISO 8601 format (eg. ‘2024-06-09T09:30:00Z’).

Validations:

  • Must be a String

train_visit[actual_time_of_arrival]
optional , nil allowed

Actual time of arrival (inbound only). Date must be in ISO 8601 format (eg. ‘2024-06-09T09:30:00Z’).

Validations:

  • Must be a String

train_visit[estimated_time_of_departure]
optional , nil allowed

Estimated time of departure (outbound only). Date must be in ISO 8601 format (eg. ‘2024-06-09T09:30:00Z’).

Validations:

  • Must be a String

train_visit[actual_time_of_departure]
optional , nil allowed

Actual time of departure (outbound only). Date must be in ISO 8601 format (eg. ‘2024-06-09T09:30:00Z’).

Validations:

  • Must be a String