Enrollments API

Creates a product and enrolls the user

POST /api/v1/users/:user_id/enrollments

Parameters

Name Description
course_id ID of the course to enroll the user in
user_id ID of the user

Request

Headers

Accept: application/json
X-Api-Token: BxmxqH4WHxz2jF1ZzxVuJgy_dAb9tiz99w
X-Api-Email: user-265@example.com

Route

POST /api/v1/users/625/enrollments

Body

{"course_id":163}

cURL

curl "http://localhost:3000/api/v1/users/625/enrollments" -d '{"course_id":163}' -X POST \
	-H "Accept: application/json" \
	-H "X-Api-Token: BxmxqH4WHxz2jF1ZzxVuJgy_dAb9tiz99w" \
	-H "X-Api-Email: user-265@example.com" \
	-H "Content-Type: application/json" \
	-H "Host: school.worksonmy.computer"

Response

Headers

Content-Type: application/json; charset=utf-8
Content-Length: 5397

Status

200 OK

Body

{
  "created_at": "2019-10-31T22:03:10Z",
  "vat_rate": 0.0,
  "subscription_amount_to_bill": 0,
  "subscription_status": "active",
  "product_id": 65,
  "user_id": 625,
  "is_active": true,
  "current_period_start": null,
  "current_period_end": null,
  "is_recurring": false,
  "currency": "USD",
  "payment_method": "admin",
  "purchased_at": "2019-10-31T22:03:10Z",
  "country": null,
  "next_period_start": null,
  "num_payments_required": null,
  "fully_paid_plan": null,
  "vat_tax_id": null,
  "id": 22,
  "meta": {
    "class": "sale",
    "url": "/sales/22",
    "name": "22",
    "description": "",
    "image_url": null
  },
  "product": {
    "created_at": "2019-10-31T22:03:10Z",
    "formatted_price": "FREE",
    "name": "Admin enrolled",
    "description": null,
    "billing_interval": "month",
    "detailed_description": null,
    "currency": "USD",
    "position": 2,
    "price": 0,
    "is_recurring": false,
    "is_published": false,
    "course_id": 163,
    "author_revenue_share": null,
    "num_payments_required": null,
    "id": 65,
    "meta": {
      "class": "product",
      "url": "/courses/163/products/65",
      "name": "Admin enrolled",
      "description": null,
      "image_url": null
    }
  },
  "coupon": {
    "created_at": "2019-10-31T22:03:10Z",
    "new_purchase_price": 0,
    "formatted_discount": "$0",
    "formatted_price": "FREE",
    "calculated_discount": 0,
    "currency": "USD",
    "discount_percent": 1.0,
    "discount_amount": null,
    "number_available": 0,
    "code": "AF3258FAA7EB7BD8F84B131B6BF02AB811A07F00",
    "name": "Admin enrollment by user-265@example.com - 624",
    "expiration_date": "2021-10-31T18:03:10-04:00",
    "product_id": 65,
    "is_published": true,
    "duration_kind": "once",
    "number_of_uses": 1,
    "class_period_id": null,
    "site_wide": null,
    "id": 49,
    "meta": {
      "class": "coupon",
      "url": null,
      "name": "Admin enrollment by user-265@example.com - 624",
      "description": "",
      "image_url": null
    },
    "product": {
      "created_at": "2019-10-31T22:03:10Z",
      "formatted_price": "FREE",
      "name": "Admin enrolled",
      "description": null,
      "billing_interval": "month",
      "detailed_description": null,
      "currency": "USD",
      "position": 2,
      "price": 0,
      "is_recurring": false,
      "is_published": false,
      "course_id": 163,
      "author_revenue_share": null,
      "num_payments_required": null,
      "id": 65,
      "meta": {
        "class": "product",
        "url": "/courses/163/products/65",
        "name": "Admin enrolled",
        "description": null,
        "image_url": null
      }
    }
  },
  "transactions": [

  ],
  "user": {
    "created_at": "2019-10-31T22:03:10Z",
    "role": "student",
    "sanitized_name": "User Name",
    "gravatar_url": "https://s.gravatar.com/avatar/f74cb7918d94d4a176d55a750b5cfaad?d=mm",
    "is_teachable_account": false,
    "author_bio": null,
    "author_bio_id": null,
    "custom_role": null,
    "custom_role_name": null,
    "primary_owner?": false,
    "show_custom_role_upgrade?": false,
    "email": "user-266@example.com",
    "notes": null,
    "affiliate_code": "305_0nekzxwk",
    "name": "User Name",
    "is_owner": false,
    "sign_in_count": 0,
    "is_student": true,
    "is_affiliate": false,
    "is_author": false,
    "src": null,
    "current_sign_in_at": null,
    "last_four": null,
    "paypal_email": null,
    "affiliate_revenue_share": null,
    "joined_at": "2019-10-31T22:03:10Z",
    "signed_up_affiliate_code": null,
    "author_revenue_share": 0.0,
    "last_sign_in_ip": null,
    "current_sign_in_ip": null,
    "id": 625,
    "school_id": 305,
    "teachable_account_id": null,
    "is_staff_user": null,
    "agree_updated_privacy_policy": true,
    "unsubscribe_from_marketing_emails": null,
    "meta": {
      "class": "user",
      "url": null,
      "name": "User Name",
      "description": "",
      "image_url": null
    },
    "transactions_gross": 0
  },
  "enrollments": [
    {
      "created_at": "2019-10-31T22:03:10Z",
      "coupon": "AF3258FAA7EB7BD8F84B131B6BF02AB811A07F00",
      "user_id": 625,
      "course_id": 163,
      "primary_course_id": 163,
      "sale_id": 22,
      "is_active": true,
      "enrolled_at": "2019-10-31T22:03:10Z",
      "percent_complete": 0.0,
      "has_full_access": false,
      "id": 16,
      "course_progress_id": 16,
      "updated_at": "2019-10-31T22:03:10Z",
      "meta": {
        "class": "enrollment",
        "url": null,
        "name": "16",
        "description": "",
        "image_url": null
      },
      "course": {
        "created_at": "2019-10-31T00:00:00Z",
        "path": "/courses/163",
        "safe_image_url": "https://process.fs.teachablecdn.com/ADNupMnWyR7kCWRvm76Laz/resize=width:705/https://assets.teachablecdn.com/icons/default-course-image.png",
        "has_published_lecture": false,
        "has_published_product": false,
        "promo_video": null,
        "name": "Course Name 17",
        "heading": "Course Heading",
        "page_title": "Course Name 17",
        "meta_description": "Course Heading",
        "friendly_url": "friendly-url-17",
        "description": "Course Description",
        "author_bio_id": 204,
        "position": 1,
        "conversion_pixels": null,
        "closing_letter": "Closing Letter",
        "image_url": null,
        "hero_image_url": null,
        "is_published": true,
        "bundled_courses_count": 0,
        "child_course_ids": [

        ],
        "preenrollment_call_to_action": "Sign up to get this course when it launches",
        "is_open": true,
        "is_accepting_preenrollments": false,
        "use_old_course_page": null,
        "skip_thank_you_page": null,
        "onboarded_at": null,
        "id": 163,
        "default_page_id": 1410,
        "checkout_sidebar_page_id": 1411,
        "certificate_page_id": null,
        "purchase_redirect_url": null,
        "mobile_thumbnail_url": "https://assets.teachablecdn.com/icons/default-course-image.png",
        "mobile_hero_image_url": "https://assets.teachablecdn.com/bg/default-hero.png",
        "post_purchase_page_id": 1412,
        "issue_certificates_manually": null,
        "is_video_completion_enforced": null,
        "is_lecture_order_enforced": null,
        "is_minimum_quiz_score_enforced": null,
        "minimum_quiz_score": null,
        "maximum_quiz_retakes": null,
        "meta": {
          "class": "course",
          "url": "/courses/163/",
          "name": "Course Name 17",
          "description": "Course Description",
          "image_url": null
        },
        "categories": [

        ],
        "author_bio": {
          "created_at": "2019-10-31T22:03:09Z",
          "headline": "MyText",
          "profile_image_url": "http://www.example.com",
          "bio": "MyText",
          "position": null,
          "user_id": null,
          "name": "Author Name",
          "id": 204,
          "meta": {
            "class": "authorbio",
            "url": "/author_bios/204",
            "name": "Author Name",
            "description": "",
            "image_url": null
          }
        }
      }
    }
  ]
}