def METHOD_NAME():
    try:
        blackout = Blackout.parse(request.json)
    except Exception as e:
        raise ApiError(str(e), 400)
    if Scope.admin in g.scopes or Scope.admin_blackouts in g.scopes:
        blackout.user = blackout.user or g.login
    else:
        blackout.user = g.login
    blackout.customer = assign_customer(wanted=blackout.customer, permission=Scope.admin_blackouts)
    try:
        blackout = blackout.create()
    except Exception as e:
        raise ApiError(str(e), 500)
    write_audit_trail.send(current_app._get_current_object(), event='blackout-created', message='', user=g.login,
                           customers=g.customers, scopes=g.scopes, resource_id=blackout.id, type='blackout', request=request)
    if blackout:
        return jsonify(status='ok', id=blackout.id, blackout=blackout.serialize), 201, {'Location': absolute_url('/blackout/' + blackout.id)}
    else:
        raise ApiError('insert blackout failed', 500)