# Create a training module

Creates a training module in the current account. account_id is always the
calling account and cannot be set from the request, and the module's token
is generated on create. The response is the same shape as reading the
module, so a follow-up read is not needed.
A created module has no steps. Add them through the training step endpoints.
Invalid input returns a 422 identifying the fields at fault. The field notes
below say which rules apply to each.

Endpoint: POST /api/v2/training
Version: 2.0.0
Security: default

## Header parameters:

  - `Rosterfy-Platform` (string)

## Request fields (application/json):

  - `success_message` (string, required)
    The end of course message, shown when a user finishes the module. HTML, maximum 64,000 characters.

  - `name` (string, required)
    The name of the module. Maximum 255 characters. Translatable: send a plain string to set it for the request locale, or an object keyed by locale such as {"en-US": "Induction"}.

  - `estimated_complete_time` (integer)
    How long the module is expected to take, in minutes.

  - `publish` (boolean)
    Whether the module is published. Until it is, the module is not visible in the portal.

  - `is_archived` (boolean)
    Whether the module is archived. The mass-archive endpoint sets this field in bulk.

  - `is_elective` (boolean)
    Whether any user who can access training may complete this module.

  - `is_inheritable` (boolean)
    Whether accounts below the owning account may use this module. Reflected in the response as nice.acts_as_native.

  - `type_id` (integer)
    The ID of the training type to categorise this module under. Used for reporting and filtering, and optional.

  - `service` (string)
    The training provider. One of online, scorm, scorm_upload or bespoke for modules Rosterfy hosts, or the code of an external provider. A module whose service is not one of the four local values reads as external, and the update endpoint ignores this field for those modules.

  - `external_id` (string)
    The ID of the module in the external training provider. Recorded when the module is synced from that provider, and sent back to it on assignment and completion.

  - `meta` (object)
    Provider and behaviour options for the module. The documented subkeys follow. On create this object is stored as sent; on update it is merged into the stored object, so omitted subkeys keep their current values.

  - `meta.onetime` (boolean)
    Whether a user is blocked from repeating the module if they do not pass on the first attempt.

  - `meta.score` (boolean)
    Whether a score is recorded. The user always moves to the next step when there is a question, and the total correct answers make up the score.

  - `meta.inform_answer` (boolean)
    Whether the user is told if their answer was correct.

  - `meta.show_correct` (boolean)
    Whether the user is shown the correct answers.

  - `meta.inform_score` (boolean)
    Whether the user is shown the percentage required to pass and their own score at the end.

  - `meta.template_id` (integer)
    The ID of the email template to send when a user finishes the module.

  - `meta.code` (string)
    The course code the module has in the external provider. Set when the module is synced from that provider.

  - `meta.original_id` (string)
    The original module ID in the external provider. Set when the module is synced from that provider.

  - `meta.source` (string)
    The name of the external provider the module was synced from.

  - `meta.height` (integer)
    The height of the SCORM frame in the portal, in pixels. Must be under 5000. Defaults to 600.

  - `meta.suspend` (boolean)
    Whether the user is forced to restart the SCORM module if they return after starting it.

  - `meta.redirect_url` (string)
    The URL the user is redirected to from the portal to take the training. Required when service is bespoke.

  - `meta.entrypoint` (string)
    The file the SCORM package starts at, usually index.html or story.html. Required when service is scorm or scorm_upload.

  - `meta.complete` (string)
    The status the SCORM file emits to tell Rosterfy the training is complete, usually complete or passed. Your SCORM provider will tell you this status. Required when service is scorm or scorm_upload.

  - `ttl` (integer)
    How long a completion stays valid, in seconds. A user is required to retake the module once it lapses, and re-completing resets the expiry. Only applied when greater than 0, and forced to 0 when can_expire is sent as false.

  - `is_library` (boolean)
    Stored, but read by nothing in the platform.

  - `form_id` (integer)
    The ID of the form a user completes before starting the module without a Rosterfy account. Setting it is also what makes the module readable unauthenticated - see the read endpoint. Cleared when anonymous_enable is sent as false.

  - `certificate_id` (integer)
    The ID of the certificate to award when the module is completed successfully.

  - `pass_score` (integer)
    The percentage a user must reach to be marked as passed, from 0 to 100. Applies when meta.score is true.

  - `sort_order` (integer)
    The position of the module where listings are ordered by sort order.

  - `scorm_upload` (string)
    URL of an uploaded SCORM zip, up to 100MB, which Rosterfy unzips and stores. Only acted on by the update endpoint; on create the field is accepted and ignored.

  - `short_description` (string)
    A short summary of the module. Not validated by the server; anything the column accepts is stored.

  - `thumbnail_url` (string)
    URL of, or an upload for, the module thumbnail. Recommended 245x150 pixels. Not validated by the server.

  - `can_expire` (boolean)
    Whether completions of this module expire. Not stored; sending it as false is what sets ttl to 0.

  - `anonymous_enable` (boolean)
    Whether the module may be completed by someone without a Rosterfy account. Not stored; sending it as false is what clears form_id and meta.template_id.

## Response 201 fields (application/json):

  - `object` (object)

  - `object.id` (integer)

  - `object.name` (string)

  - `object.short_description` (string | null)

  - `object.thumbnail_url` (string | null)

  - `object.account_id` (integer)

  - `object.deleted_at` (string | null)

  - `object.created_at` (string)

  - `object.updated_at` (string)

  - `object.success_message` (string)

  - `object.is_archived` (integer)

  - `object.is_elective` (integer)

  - `object.estimated_complete_time` (integer)

  - `object.ttl` (integer)

  - `object.pass_score` (integer)

  - `object.is_library` (integer)

  - `object.publish` (integer)

  - `object.service` (string)

  - `object.external_id` (string | null)

  - `object.meta` (array)

  - `object.token` (string)

  - `object.sort_order` (integer)

  - `object.certificate_id` (string | null)

  - `object.form_id` (string | null)

  - `object.type_id` (string | null)

  - `object.is_inheritable` (integer)

  - `nice` (object)

  - `nice.publish` (string)

  - `nice.account_id` (integer)

  - `nice.account_url` (string)

  - `nice.external` (boolean)

  - `nice.has_certificate` (boolean)

  - `nice.account_name_path` (string)

  - `nice.is_foreign_account` (boolean)

  - `nice.acts_as_native` (boolean)

  - `nice.number_of_steps` (integer)

  - `nice.number_of_questions` (integer)

  - `relations` (object)

  - `relations.account` (object)

  - `relations.account.object` (object)

  - `relations.account.object.id` (integer)

  - `relations.account.object.parent_id` (integer)

  - `relations.account.object.account_type_id` (integer)

  - `relations.account.object.path` (string)

  - `relations.account.object.name` (string)

  - `relations.account.object.config` (object)

  - `relations.account.object.config.active_settings` (array)

  - `relations.account.object.meta` (array)

  - `relations.account.object.visibility_rules` (array)

  - `relations.account.object.status` (string)

  - `relations.account.object.status_reason` (string | null)

  - `relations.account.object.sort_order` (integer)

  - `relations.account.object.start_timestamp` (string | null)

  - `relations.account.object.end_timestamp` (string | null)

  - `relations.account.object.notes` (string | null)

  - `relations.account.object.contact_firstname` (string | null)

  - `relations.account.object.contact_lastname` (string | null)

  - `relations.account.object.contact_email` (string | null)

  - `relations.account.object.contact_phone` (string | null)

  - `relations.account.object.support_manager_email` (string)

  - `relations.account.object.allow_deletion_request` (integer)

  - `relations.account.object.organization_type` (string | null)

  - `relations.account.object.contract_start_date` (string)

  - `relations.account.object.contract_end_date` (string)

  - `relations.account.object.billing_contact_email` (string)

  - `relations.account.object.billing_support_email` (string)

  - `relations.account.object.is_enabled` (integer)

  - `relations.account.object.additional_billing_support_email` (string)

  - `relations.account.object.delete_requested_at` (string | null)

  - `relations.account.object.is_archived` (integer)

  - `relations.account.object.trial_ends_at` (string | null)

  - `relations.account.object.can_erase` (integer)

  - `relations.account.object.deleted_at` (string | null)

  - `relations.account.object.is_erased` (integer)

  - `relations.account.object.created_at` (string)

  - `relations.account.object.updated_at` (string)

  - `relations.account.nice` (object)

  - `relations.account.nice.rrn` (string)

  - `relations.account.nice.address` (string)

  - `relations.account.nice.address_oneline` (string)

  - `relations.account.nice.account_type_id` (string)

  - `relations.account.nice.account_type_id:value` (integer)

  - `relations.account.nice.account_type_id:array` (string)

  - `relations.account.nice.allow_deletion_request` (string)

  - `relations.account.nice.contact_firstname` (string)

  - `relations.account.nice.contact_lastname` (string)

  - `relations.account.nice.contact_phone:qr_code_value` (string)

  - `relations.account.nice.contact_phone` (string)

  - `relations.account.nice.contact_phone:raw` (string)

  - `relations.account.nice.contract_end_date` (string)

  - `relations.account.nice.contract_end_date__dayofweek` (string)

  - `relations.account.nice.contract_start_date` (string)

  - `relations.account.nice.contract_start_date__dayofweek` (string)

  - `relations.account.nice.name` (string)

  - `relations.account.nice.notes` (string)

  - `relations.account.nice.organization_type` (string | null)

  - `relations.account.nice.organization_type:value` (string | null)

  - `relations.account.nice.organization_type:array` (string | null)

  - `relations.account.nice.status` (string)

  - `relations.account.nice.status:value` (string)

  - `relations.account.nice.status:array` (string)

  - `relations.account.nice.status_reason` (string)

  - `relations.account.nice.created_at` (string)

  - `relations.account.nice.url` (string)

  - `relations.account.nice.branding_name` (string)

  - `relations.account.nice.branding_subtitle` (string | null)

  - `relations.account.nice.branding_logo` (string | null)

  - `relations.account.nice.branding_logo_mono` (string | null)

  - `relations.account.nice.branding_logo_stacked` (string | null)

  - `relations.account.nice.branding_banner` (string | null)

  - `relations.account.nice.branding_description` (string | null)

  - `relations.account.nice.branding_primary_color` (string)

  - `relations.account.nice.branding_complimentary_color` (string | null)

  - `relations.account.nice.branding_secondary_color` (string)

  - `relations.account.nice.register` (boolean)

  - `relations.account.nice.organisation_contact` (string)

  - `relations.account.nice.has_subaccount_approved_email_template` (boolean)

  - `relations.account.nice.has_subaccount_rejected_email_template` (boolean)

  - `relations.account.nice.parent_account_name` (string)

  - `relations.account.permissions` (object)

  - `relations.account.permissions.read` (boolean)

  - `relations.account.permissions.update` (boolean)

  - `relations.account.permissions.delete` (boolean)

  - `relations.certificate` (string | null)

  - `permissions` (object)

  - `permissions.read` (boolean)

  - `permissions.update` (boolean)

  - `permissions.delete` (boolean)

