1. Get all locations: https://www.mytime.com/api/mkp/v1/docs#/Location/get_companies__company_id__locations
export COMPANY_ID=
export LOCATION_ID=
curl "https://www.mytime.com/api/mkp/v1/companies/$COMPANY_ID/locations?include_business_hours=true&include_mobility=true" \
-H "accept: application/json" \
-H "content-type: application/json"
2. Get all class sessions: https://www.mytime.com/api/mkp/v1/docs#/ClassSession/get_classes_sessions
export START_DATE=202X-XX-XX
export END_DATE=202X-XX-XX
curl "https://www.mytime.com/api/mkp/v1/classes/sessions?location_id=$LOCATION_ID&start_date=$START_DATE&end_date=$END_DATE&company_id=$COMPANY_ID&category=true" \
-H 'accept: application/json' \
-H 'content-type: application/json' > sessions.json
export SESSION_ID=$(cat sessions.json | jq '.sessions[].id')
export SESSION_ATTENDEE_ID=$(cat sessions.json | jq '.sessions[].session_attendees[].id')
3. Create the user: https://www.mytime.com/api/mkp/v1/docs#/User/post_users
curl 'https://www.mytime.com/api/mkp/v1/users' \
-H 'accept: application/json' \
-H 'content-type: application/json' \
-d "{\"company_id\":$COMPANY_ID,\"first_name\":\"Test\",\"last_name\":\"Test\",\"email\":\"test@mytime.com\",\"password\":\"123\",\"password_confirmation\":\"123\",\"phone_number\":\"\",\"country\":\"US\",\"zip_code\":\"94111\",\"send_welcome_email\":true,\"associate_client_id\":null,\"from_mkp\":true,\"recaptcha_token\":null}" > user.json
export AUTHORIZATION=$(cat user.json | jq '.user[].authentication_token')
4. Update or create the client for logged in user: https://www.mytime.com/api/mkp/v1/docs#/Client/put_user_client
curl 'https://www.mytime.com/api/mkp/v1/user/client' \
-X 'PUT' \
-H 'accept: application/json' \
-H 'content-type: application/json' \
-H "authorization: $AUTHORIZATION" \
-d "{\"company_id\":$COMPANY_ID,\"client\":{\"preferred_language\":\"en-US\"}}" > client.json
5. Create a child for the current user: https://www.mytime.com/api/mkp/v1/docs#/Child/post_user_children
curl 'https://www.mytime.com/api/mkp/v1/user/children' \
-H 'accept: application/json' \
-H 'content-type: application/json' \
-H "authorization: $AUTHORIZATION" \
-d "{\"company_id\":$COMPANY_ID, \"first_name\":\"Test\"}" > child.json
export CHILD_ID=$(cat child.json | jq '.child[].id')
6. Create a new session enrollment: https://www.mytime.com/api/mkp/v1/docs#/SessionEnrollment/post_classes_enrollments
6.1 WITHOUT TAKE THE PAYMENT
curl 'https://www.mytime.com/api/mkp/v1/classes/enrollments' \
-H 'accept: application/json' \
-H 'content-type: application/json' \
-H "authorization: $AUTHORIZATION" \
-d "{\"company_id\":$COMPANY_ID,\"location_id\":$LOCATION_ID,\"session_id\":$SESSION_ID,\"attendees\":[{\"children\":[$CHILD_ID],\"for_client_count\":0,\"session_attendee_id\":$SESSION_ATTENDEE_ID}],\"referrer\":\"express_checkout\",\"no_pay\":true}" > enrollment.json
6.2 TAKING THE PAYMENT
Check: How to save a credit card in the user's wallet using Stripe
export CARD_ID="cus_ROXXXXXX|pmXXXXXXXX"
curl 'https://www.mytime.com/api/mkp/v1/classes/enrollments' \
-H 'accept: application/json' \
-H 'content-type: application/json' \
-H "authorization: $AUTHORIZATION" \
-d "{\"company_id\":$COMPANY_ID,\"location_id\":$LOCATION_ID,\"session_id\":$SESSION_ID,\"attendees\":[{\"children\":[$CHILD_ID],\"for_client_count\":0,\"session_attendee_id\":$SESSION_ATTENDEE_ID}],\"referrer\":\"express_checkout\",\"no_pay\":false,\"card_id\":$CARD_ID}"
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article